Reading a Rotary Switch
In my current project I have a rotary switch as a sort of menu selector.
I could use 6 IO pins to read the state of the switch but with adding resistors I can find the position using one analog input pin.
This is probably common knowledge, but it’s new to me as I have never had the use for a rotary switch before. But for anyone that could have a use for it, this is what I did.
Between the contacts (in my case 6 positions) I added a 1k resistor. Then feeding 5V to the first value in the chain you get different voltage from any position in the resistor chain. This is easily read by an analogue input on any microcontroller.
So with using resistors and one analogue pin you can read any rotary switch position and with a couple of them probably make a very complex menu system.