Let's Make Robots!

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Same principle you can also use for tactile sensors on your robot :)

Back in the late 70's, before IR remotes, RCA and others had wired remotes on their VCR's. All the function buttons had resistors accross them, (different values), and the total resistance was read with an A/D converter. This gave you maybe a dozen functions with only 2 wires.

This is and excellent discovery!

(Quick digression: I also made this discovery around about the same time I invented "instant tea" using a corning process. Trouble is with most of these things, some other sod with far more money makes it to market first!!)

You're right in that it's a common technique ("resistor ladder") BUT the amazing thing about "discovering" for yourself these things (rather than reading them off some textbook) is that it proves you have the "think-outside-the-box-ability!" Folk who "discover" like this rather than "plagiarising" from someone else's discovery will invariably eventually discover something that some rich sod hasn't already discovered!

I'm looking forward to watching yo do that! Thanks for sharing.

Thank you very much for this comment. This is probably the one of the nicest thing anyone has said to me. And yes, if I had googled a bit I would have found that this is not new, but it’s still a great feeling figuring it out on your own.

Nice tip!

MAKE did a whole series of videos on Basic electronics explained in a fun way, which Gareth collected in a post. It was recently updated with a video on switches, which mentions rotory switches. Your tip complements this nicely.  

I love the Collin's Lab videos and it’s highly recommended for anyone starting up in electronics.