Quote:
Originally Posted by andreboos
Just one more option to consider:
If you're out of Digital I/O ports (like I was this year), you can also wire to the analog breakout. Connect +5v and Signal when the limit switch is engaged, and then check in code whether the analog channel reads above or below 2.5V.
|
If you are going to connect it using an analog channel, you need some simple circuit than just a switch. If I understand you correctly, you are connecting +5 and Signal to the "Normal Open" or "Normal Close" and "Common" contacts of the switch. In other words, when activated, you either short signal to +5 or leave signal floating. Leaving the signal pin unconnected will read random values. If you really want to use analog channel, you need to use at least one resistor (e.g. a 10K resistor connected between +5 and Signal), then connect the Normal Open to signal and Common to Gnd. When the switch is activated, the signal pin will give you 0V (shorted to Gnd). When the switch is not activated, the signal pin will give you approx. 5V (open).