It does the opposit
Here are pictures of my wiring :
It does the opposit
Then the switch itself is incorrectly wired.
Did you test the switch contacts with a DMM to identify the pins, or look up the switch specifications? How do you know that you are on the right pins?
Can we see a non-fuzzy image of the switch?
I haven't look with a DMM because I don't have a DMM. The switch specifications are on mc master carr : McMaster-Carr
Otherwise, when I say right and left it is when I look at the switch.
I can't see anything wrong with the wiring.
Try different UNO pins maybe 6 and 7.
If that does not work I suspect that one of the switch connections under the heatshrink is bad
The positioning of the lugs suggests pin 2 (black) on the switch is common. It's unlikely that the pinout differs from the usual, but remotely possible. The specs don't call out the pin functions at all. ![]()
For testing, don't use the switch at all. Just alternately, momentarily ground the input pins with a jumper. That will locate the problem either on the switch or Arduino side.
It work!!! Thanks!!!!
So, just a loose connection probably
Now go back to the original pins and replace the jumper wires... those might be bad, intermittent.
I look at the switch.
You either have unusually small hands or that's the cutest giant toggle switch I have ever seen.
a7
For @b_d, the OP. An alternate concept for handling an SPDT center-off toggle.
Wire 5V to one side of the switch(ON), GND to the other(ON), and wire the center pin of the switch to your analog input. Wire a 2.2k resistor from 5V to an analog input, let's use A0. Wire another 2.2k resistor from GND to your analog input.
Now, in your software, if the analog input reads "around 500", your toggle is centered. If it reads "nearly zero", your toggle is thrown to one side, and if it reads "around 1000", your toggle is thrown to the other side.
This is a very different approach, but I think it's a worthwhile learning exercise, and ultimately, it means you can handle more toggle switches with fewer inputs.
Working out how to economically determine which of the three states the toggle is in is a coding exercise.
This is all worded for a 5V Nano, with a 10-bit resolution for analog reads.
YMMV.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.