Original may be found at: http://stafney.com/~tstafney/opensource/ Rational: Using a DB9 connector we can "read" and "write" to several pins to set/get if they are on (+ voltage) or off (- voltage). This allows us to recognize an ON or OFF state on some pins and to set an ON or OFF state on others. This means we can illuminate an LED on any pins we can SET to on/off and we can receive button pressed notification on pins we can GET as on/off. ********************************************* DB9 female (to the computer) 5 4 3 2 1 --------------- \ * * * * * / \ * * * * / --------- 9 8 7 6 (the male is a mirror image) ********************************************* Pin Name Description --- ---- ----------- 1 DCD Data Carrier Detect 2 RD Receive Data (a.k.a RxD, Rx) 3 TD Transmit Data (a.k.a TxD, Tx) 4 DTR Data Terminal Ready 5 SGND Ground* 6 DSR Data Set Ready 7 RTS Request To Send 8 CTS Clear To Send 9 RI Ring Indicator * - Note that this is a "logical" ground that allows the serial port to determine what voltage means "on" or "off". A baseline if you will. For the purposes of actually grounding (from an electricity perspective) we can must use the "case" of the connector (which is physically grounded) to complete our circuit. We can read pins 1, 6, 8, 9 We can write pins 4, 7 ********************************************* Buttons: By connecting a pin we can read (A) to a pin we know has voltage (B) THROUGH the leads of a button or switch we can, when the button is pressed, put voltage on (A) and can detect it in software. Lights: By connecting a pin we can write (A) to a physical ground THROUGH a LED we can, by setting the pin high, turn on the LED. Remember that LED's require a resistor on the annode (+) side to limit current so as not to burn out the LED (you can use Ohm's law to determine what size resistor). The annode side of the LED must be connected to the pin (A) so that the voltage flows in the proper direction. LED's are voltage direction sensitive. Resistors are not. For my particular implementation I used a 1.7V 40mA red LED. My serial port procduces +11V. The formula for determining resistor size is: Ohms = ((input voltage) - (LED voltage)) / Amps In my case: (11 - 1.7) / .04 Or: 232 Ohms When choosing a resistor, aim high. Pick the one that is AT LEAST the amount you need. Not enough resistance will burn out the LED while too much will just cause it to be less bright. ********************************************* You can even get a fancy little box to house all of this in. I believe Radio Shack sells 'em for about $3. I like to mount a female connector on the outside of the box. Then I can use a standard serial cable to connect the box to my PC as well as use the same serial cable to connect my RD-232 breakout box to my PC (which I use for testing - and YOU should too). I suspect if you don't have a serial cable and you don't want to buy a cable AND a female DB-9 then you can just hardwire the cable directly into your black box. I think you can buy EVERYTHING to build this from Radio Shack for under $10 serial cable not included ;-) Have fun! Todd