I have a button that when push turns on a little light (light blinks; like a counter) - is there an easy way to hijack this signal so that my windows box can also detect if the button is pushed? I have access to RS232 port and USB; I can also read from the RS232 port. I don't really care what signal it sends so long as there is something that I can record once a button is pushed.


If you are writing a Window's application and it is in that environment that you want to capture the button press one rather easy way to achieve this is to have the Windows program open up a Com: port interface. The Com: port can come from either a hardwired UART port in the computer OR it could come from a plugin USB to Serial adapter cable.

You would wire up the button circuit in the external device to the CTS handshake line input to the Com: port. It may take a small transistor adapter circuit with some added resistors to achieve the proper signal levels to enable the connection to work correctly. The nature of the adapter, if needed, will depend a lot on the nature of just how the switch button circuit works and thus it is not possible to suggest an appropriate circuit for you.

Once you get the circuit interface wired up you can have the Windows program setup to monitor for event messages that trigger when ever the switch is pressed and cause the Com: port CTS line to toggle state. In the event handler logic you can add whatever code is appropriate for your application. The decided advantage of this approach is that there is no data transfer software protocol and handshaking to mess with in the Windows program.

Note that I've used this technique in the past to allow a guitar style foot pedal to trigger inputs into a Window's software program that was used to support calibration of electronics products on a production line in a factory.

| improve this answer | |
  • \$\begingroup\$ Here is a diagram of a simple RS232 single bit input: cedarlakeinstruments.com/SharedFiles/io.html \$\endgroup\$ – lyndon Oct 30 '13 at 0:21
  • 1
    \$\begingroup\$ @Lyndon - Those circuits are a great start. If one is using an actual RS232 port for this type of 1-bit input I like to eliminate the need for an additional +9 -> +12V supply by having the PC program set the RTS output to a state so that that Com: port output pin goes to the +V state. Then the pullup for the CTS input can connect to the RTS line. \$\endgroup\$ – Michael Karas Oct 30 '13 at 0:39
  • \$\begingroup\$ @MichaelKaras this sounds VERY promising - I'm going to try this tomorrow! very excited. \$\endgroup\$ – Ahdee Oct 30 '13 at 2:18
  • \$\begingroup\$ Ack! I linked to an old version of the schematic. Here's the updated one: cedarlakeinstruments.com/blog/archives/46 I used this to read an arcade pushbutton into a .NET program for a small project. \$\endgroup\$ – lyndon Oct 30 '13 at 19:05
  • \$\begingroup\$ @lyndon thanks - I ended up hacking an old keyboard - that turned to be the easiest. thanks. \$\endgroup\$ – Ahdee Nov 1 '13 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.