My final product is a switchboard. But for now I'm trying to run a few tests.
But i have no clue what pins on my Arduino Nano i am connecting what to.
Could i get some help? because all I know is that I'm connecting the common prong to GND.
Another note is that the switch i am using is this
I'm going to use the switch to turn on and off an LED, and will be using a breadboard
Do you need to register all 3 positions on the switch? Connect the common to Arduino ground, and each of the other pins to an Arduino input pin configured for INPUT_PULLUP.
If not, then the wiring shown in the official tutorials works fine.
Set the pinMode for each input to INPUT_PULLUP. When center off, both inputs read HIGH. A closed side input will read LOW. As shown, the upper input will read LOW and the lower input will read HIGH.
Hi,
What is the purpose of this "final product"?
I assume that you're doing more than illuminating an LED, otherwise you won't need an Arduino.
You can use any I/O pin on the processor for the switch and for the LED. These are labeled as D0-D13 and A0-A7. I would avoid using D0 and D1, as they are used for serial communications and may interfere with your program.
Are you asking for a circuit design and / or a code snippet to read the switch and to light up the LED?
You can not use A6 and A7 on the Nano for digital I/O. Analog input only.
For a SPDT switch with center off, it should be possible to use a single analog input and a voltage-divider type circuit.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.