Disclaimer: This tutorial is for simplified demonstration/educational purposes and not intended for production applications. We cannot be held responsible for any misuse, errors, or damages. Use at your own risk.
One of the most common questions someone learning electronics may think about is how to get a computer to perform basic operations, such as controlling lights and other systems. A simplified version of this problem is learning how to get an LED blinking from your computer.
There are many ways to get the job done and common solutions typically require micro-controllers. However, is it possible to accomplish this without an understanding of micro-controllers and programming.
Let’s go into the basics of what a serial interface is. A serial interface is a way for the computer to communicate to other systems by sending and receiving a stream of 1’s and 0’s, which dictates what message is sent. For example, for a computer to send the letter ‘A’, it needs to send the ASCII representation (0x41), which is a way for letters to be translated into binary representations. In this case, 0x41 is a hexadecimal representation for ‘A’ and has an associated binary representation of 0b0100_0001. The least significant bit is sent first.
Order of bit transmission: [StartBit] [Least Significant Bit] …[Most Significant Bit] [Stop Bit(s)]
This could look like: [Start Bit] [01 00 00 01] [Stop Bit(s)]
A transmitted 1, a logical high, represents a negative voltage and a 0, a logical low, represents a positive voltage (due to the electrical/logical definition of Serial Interfaces).
2. Setting up Your computer
So, we need to get our computer hooked up. To do this, we need a USB to Serial Adapter.
a device that converts USB signals to a different form that will make it more convenient for us. I happened to use Office Depot’s Ativa, but any one you purchase should work (provided it is compliant to RS-232).
First, plug the USB to Serial to your laptop. We now need to figure out the name of our adapter. On Windows 10, we can open up Device manager to figure it out. Below, we see my device’s name is COM3, which we will need later. Yours may be different, so please check.
Next, we need to open PUTTY (or any terminal that can perform serial communication). Set the Serial Line to the device name and the speed to 75. Make sure to select the connection type of Serial. Note: if you do not select the correct (Baud Rate) speed of 75, the LED will blink very rapidly for your eyes and it will appear that it isn’t blinking, even though it is.
If you click open and you see the image below, you can proceed further. Otherwise, recheck your PUTTY settings above or go to the troubleshooting section at the end of the post.
3. Connect LED!
So now we need to get our hands dirty. Grab three wires and plug them into the adapter’s pins of 2,3, and 5. Pins 2 and 3 are the RECEIVE (Yellow below) and TRANSMIT (RED Wire below) of the computer’s serial interface, respectively. Pin 5 (Black below) is ground (GND). Next, hook up a resistor whose anode is connected to the Transmit Pin (3). Make sure to add a resistor in series with the LED, where the resistor is also connected to ground. Double check the connections to see if they are consistent. If you flip the LED, the blinking example will still work, but will invert. Also, if you short the Receive and Transmit pins of the serial interface, you will do a loop back test in which the computer will print out what it send. A good test indeed!
Here is a closer look at the serial interface.
Next fire up PUTTY based on the setup above and try typing on the keyboard. Every time you type, you should see a blink! And, you will see your character appear on your screen!
4. TroubleShooting Serial Driver Issue
If you couldn’t get the blinky demo working, it could be that the USB to Serial Adapter’s drivers aren’t set up properly. Here is a fix that worked for me. Open up Device Manager again. Go to your device, right click, and then click update driver.
Go for “Browse my computer” for driver software.
Click “Let me pick” below.
Select the appropriate driver and then click Next. If you have a CD, you can also click “Have Disk.” In my case, I just clicked Next.
Now give the demo another try and dig in to troubleshoot if other issues could be the culprit.
Please let us know your thoughts and how we can improve this! Thanks for reading!
We at Simplonics can deliver robust connectivity solutions tailored for your application.