Control an LED via USB/RS232 adapter

From ThorstensHome
Revision as of 12:44, 30 September 2012 by WikiSysop (Talk)

Jump to: navigation, search

Today I lighted an LED using my USB to serial adapter. Here is how it looks:


Here is how it works:

  • Connect your USB to serial adapter to your computer.
  • Find out what device name it got using dmesg:
[29231.270163] usb 2-1.6: pl2303 converter now attached to ttyUSB0
in this case it is /dev/ttyUSB0
import serial, time
conn = serial.Serial('/dev/ttyUSB0',
  • know that you can probably hold an LED directly to the pins as they should contain current limiters.
  • know that PIN 5 holds 0V and all other PINs hold 0V or +5V usually
  • So risk it and hold the long pin (plus) to PIN 3 and the short one to PIN 5

Why does this work? Because there is a limiter that limits the power so the LED does not break. If I connect RI and TXD then via an LED it shines, plus RI's state, read by python, turns from off to on.

See also