Home > Software design >  How can I use a serial port to listen to if toggles are switched?
How can I use a serial port to listen to if toggles are switched?

Time:06-13

In my software I need to detect when an operator toggles one of two miniature toggle electric switches:

enter image description here

and which one.

I want to do this with as little external hardware as possible. I was thinking that maybe I could use a USB to serial cable?

Looking at the enter image description here

It seems that I could connect a voltage source trough the toggle 1 to pin 8 (CTS) and to ground? Likewise it seems that I could connect a voltage source trough the toggle 2 to pin 6 (DSR) and to ground?

Will this work? Is there a better way to do this only using a USB to serial cable?

CodePudding user response:

For the sake of sparing you the work of reposting to the electronics exchange:

According to this document, setting CTS on means a voltage of at least 3V on the CTS line, relative to GND. Similarly, setting CTS off means a voltage of at least -3V on the CTS line, relative to GND. So you'd need two voltage sources, one for > 3V (GND to Serial GND) and one isolated one for <-3V (Plus to Serial GND).

DSR functions similarly, according to the document.

Also, your switch looks like an SPST. You'd need at least an SPDT for this if you want to avoid using resistors.

  • Related