Serial Port LED flasher

Need a simple software controlled indicator? A green light when there’s unread email in your inbox? Red flashing alarm showing that the last nightly software build is broken? Or perhaps you really need a “do not disturb” sign that you can control without leaving your keyboard.

serial-led

Software-driven indicator lights are one of those things that seem like they should be simple — and they are. The problem is that today’s computers make them more difficult than before. “Once upon a time” every PC had a parallel printer port and it was the doorway to thousands of I/O devices back in the day. Today, USB is dominant and it takes a bit more than a simple out() or in() command in C to get access to the outside world from the desktop computer. This is probably why we see so many hackers turning to Arduinos to do such a simple task: it’s what’s available and well known. The problem is that it’s overkill and requires that you learn yet another toolkit.

A very simple way to control an LED is from a computer’s serial RS232 port. While few new PCs are coming with RS232 ports, they all have USB ports and USB to RS232 adapters are a dime a dozen. Or at least not much more than $5. So here’s how to get an RS232 LED indicator working.

We can hang a modern high efficiency LED off one of the RS232 data flow control lines and control it by software. Microsoft .NET, the Win32 API and Linux all offer libraries to control the serial port.

OK, enough talk, here’s a schematic:

DB9-LEDFour components: one of which is more for warm fuzzies than anything else. Pin 5 on the RS232 adapter is ground and pin 4 is the Data Terminal Ready (DTR) control line. R1 is used to limit current to the LED. Depending on the serial port, the voltage at pin 4 may range from -12V to +12V. Since the reverse voltage on most LEDs tops out at around -5V, we add a signal diode to give more reverse voltage protection. For most USB-serial adapters on the market, this probably isn’t needed, since their voltage tends to not drop below -5V, but let’s be safe. R1 can be adjusted depending on the color of the LED and how bright you need it to be. In this circuit, it’s about as low as I’d consider safe: with a red LED the circuit will draw about 10mA, which is about as much as most common serial translator chips will safely provide. It works with the adapters I’ve tested, but a safer value would be around 470 ohms. The limiting factor is the drive of whatever chip is powering the RS232 lines. USB itself can provide much more current than we need here.

You can build your own from the diagram shown above if you have the parts and experience. If you just need to get to the end result right away, we provide the complete unit shown in the picture below for $14.98 (shipping included) It drives a high-brightness white LED directly from a PC serial port (or USB-serial adapter). Complete documentation on programming it with the .NET SerialPort class is included along with a sample program written in C#. If you would like to see the code, it is on GitHub at this repository.

db9-LED
Serial LED controller………………….$14.98



This product has been discontinued.