Need help with using a rotary switch for a HID input

So I am planning to build a switch box to use in DCS, and I want to build something like the SU-25T bomb panel, which includes 4 on-off-on switches and 2 rotary switches, 4 position and 9 position respectively. However, I think that if I connect each pin from the rotary switch to the arduino I will run out of available pins and will not be able to fit in my other 4. So is there any way to wire the rotary switches so I do not use 13+ pins?

How about using a bunch of resistors and use two analogue inputs instead?

Don't forget that the analog pins can act as digital ones too.

Sorry if this is a bit much to ask, but how could I wire that up? Again i am sorry to ask as I have very limited experience with projects like this

Another thing to consider is what comes next. Are you going to make more panels? If so, consider using something with more pins. In projects like this, people seem to end up with multiple megas as their cockpits evolve.

Just wire it so it looks electrically like a potentiometer.

I didn't read this in depth so cannot comment on its accuracy - instructables are often held in low esteem here - but, it does illustrate the principle @anon73444976 mentions.

There's an Arduino tutorial on this which uses the CD4021 chip as a parallel-in, serial-out, shift register. Three pins are required on the Arduino, but you can connect up to 8 pins to the CD4021, and you just read them in one at a time. You can even cascade multiple CD4021s using the same three Arduino pins. I think the 74HC165 may also work.

https://www.arduino.cc/en/Tutorial/Foundations/ShiftIn

Edit: You might have to have high-value pullup or pulldown resistors on the shift register inputs so they won't be floating.

Also, there is the 74HC148 8-to-3 encoder, which gives a three-bit binary value for the 1 of 8 inputs which is low. You wouldn't have to clock that data in, just read the value of the three pins.

But! Take into account that every time you move your rotary switch from one stop to the next, there is ALWAYS an OPEN circuit for a short length of time. Best to have a push button switch to tell you Arduino to now read the switch position.
Paul

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.