使用串行端口连续LED开 - 关 [英] Make LED ON-OFF continuously using serial port

查看:100
本文介绍了使用串行端口连续LED开 - 关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想连续开启和关闭LED .LED连接在PC串口的输出端。请给我合适的方法来满足我的要求。我想用.NET或C实现它。 C ++。请给我合适的解决方案和说明。由于我对这些语言了解不多,请明确说明解决方案。



谢谢和问候,

Tushar

Basically I want to make LED ON and OFF continuously.The LED is connected at the output of the serial port of the PC.Please give me suitable method to fulfill my requirement.I want to implement it using .NET or C or C++. Please give me suitable solution with explanation.As I don't know much more about these languages please specify solution clearly.

Thanks and regards,
Tushar

推荐答案

你通过什么连接LED?你只是把针插入端口吗? :S $ / $


串口并不是一种直接打开和关闭电源的方法。它们是一个接口,通常用于需要某些信号的硬件。



你打开一个串口连接,发送设备知道的信号(命令)如何解释,你得到你正在寻找的结果。



如果你的设备上有一个LED,并配置了可寻址的命令通过串口,您需要制造商提供的指令,以找出它希望循环供电的代码/命令/信号。从那里开始,您需要处理 SerialPort [< a href =http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspxtarget =_ blanktitle =New Window> ^ ]类。



Hth。



干杯。
What do you have the LED connected through? Do you just have pins stuck in the port? :S

Serial ports aren't meant to be a way to cycle power on and off directly. They are an interface, usually to a piece of hardware that expects certain signals.

You open a connection to a serial port, send the signals (commands) the device knows how to interpret, and you get the result you're looking for.

If you have a device with an LED on it, and it's configured with commands that are addressable via the serial port, you'll need the instructions from the manufacturer to find out what codes/commands/signals it is expecting to cycle power. From there, you have some work to do with the SerialPort[^] class.

Hth.

Cheers.


有一个串行通信的资源很多,从专用网站到论坛帖子到数十年前的书籍。在.NET中,使用System.IO.Ports.SerialPort构建一个简单的应用程序非常容易。



在RS232中,主机和设备之间的传输是(部分)由给定导线上的电压(Tx / Rx)相对于地线限定。因此,您在技术上可以将LED连接到Tx和Gnd线,并通过写入/不写入数据来打开和关闭它。



这不是背后的目的这样的联系。如果您需要了解串行端口编程,请在MSDN中探索System.IO.Ports.SerialPort。如果您只想控制输出线,您真的想使用数字I / O板。 Amplicon和Measurement Computing(以及其他)提供各种价格的模拟和数字I / O板。
There are a lot of resources on serial communications, from dedicated web sites to forum posts to decades-old books. In .NET, it is really easy to build a simple application using System.IO.Ports.SerialPort.

In RS232, transmissions between host and device are (partially) defined by voltage on the given wire (Tx / Rx) relative to the ground wire. So, you technically could connect an LED to the Tx and Gnd lines and turn it on and off by writing / not-writing data.

This is not the purpose behind such a connection. If you need to understand serial-port programming, explore System.IO.Ports.SerialPort in MSDN. If you simply want to control an output line, you really want to use a digital I/O board. Amplicon and Measurement Computing (among others) offer a multitude of analog and digital I/O boards of various prices.


您可以使用DTR(pin4)和/或RTS(pin7)来实现控制一个LED。你需要在DTR(和/或RTS)和GND之间串联一个电阻和一个LED串联。

这些信号实际上通常用于为RS422转RS232转换器供电,所以应该有足够的电源供电一两个LED:)
You can use the DTR (pin4) and/or RTS (pin7) to control a LED. You need to use a resistor and a LED in series connected between DTR (and/or RTS) and GND.
These signals are in fact often used to power RS422 to RS232 converters so should have enough power for a LED or two :)


这篇关于使用串行端口连续LED开 - 关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆