I am developing a multi-part project for my lathe. In part 1 I'm adding an RPM display. Included in the circuit is a 3-position 4-pole switch. I want the Arduino to "know" what position the switch is currently set to.
I figured that I could use an analog pin (say pin 2) to tell the difference by adding a different resistor to each switch position and connecting the 3 resistors to that pin.
My circuit is as follows:
<Arduino 5V pin>----<10K resistor>----<switch position 1>----<Arduino pin 2>
<Arduino 5V pin>----<5K resistor>----<switch position 2>----<Arduino pin 2>
<Arduino 5V pin>--------<switch position 3>----<Arduino pin 2>
I figured that this should produce values using analogRead of 0, 500 (or so) and 1023 depending on the switch setting.
However, calling analogRead on the pin produces 1023 every time.
Then it's up to you, reading them vi a single input saves you one pin but is more complex both hardware and software wise. Not rocket science but a lot more complex then simple a wire and digitalRead().
Instead of the text, try making a hand drawing of how you connected it and upload the photo here. But hopefully you already spot your error when you do
Now add two resistors between 5v and GND and repeat your little exploratory lesson with the 3 nodes you now have.
Do this with different resistors and see if you notice anything.
It sounds like your wiring and measurements are all correct - as in, what it should be based on description, albeit not on what you yourself expected.
Your error: a resistor does not change voltage by itself. Putting a 5k resistor on a 5V line doesn't change the voltage. What you want is a voltage divider - and that's what you got in the final setup.
Your initial conception varied the current. If you put LEDs next to each resistor, you would have gotten 3 different brightnesses.
But the Arduino input looks at voltage, not current. Starting with 5V, you want to split it up across the steps so you can see the division.
Your initial conception was 'refueling' each step to full 5V.
Hope that helps.