6-pole rotary switch -Arduino

Hi

I need to use a 6-pole rotary switch in my project.

One way is to designate 6 digital pins of Arduino but this will engage 6 pins.

Another way is to use one analog pin with some potential dividers.

What should be the ideal way to do?

How can you expect an answer when you do not tell us what the switch is supposed to do????

Paul

And tell us how many positions each pole has and are they each spst or what?

I would use the analog approach. Bought such a shield stacked on an UNO, also having an LCD, and it works fine.

You only 3 digital inputs for those 6 different states...

Paul_KD7HB:
How can you expect an answer when you do not tell us what the switch is supposed to do????

Paul

And tell us how many positions each pole has and are they each spst or what?

First of all, extremely sorry. It is single-pole-six-position rotary switch for selecting permanent operating conditions.

hammy:
You only 3 digital inputs for those 6 different states...

That sounds interesting, would you please provide more details or some link to understand.

Make a ladder of resistors, from Vcc to GND. Use some 2 kOhm resistors. Connect the various points of the ladder to Your selector 6 pins. Connect the common to athe analog input and add a 100 kOhm resistor from the controller analog pin to Vcc.

abuhafss:
What should be the ideal way to do?

Depends.
Do you need all the other pins.

If you have 6 spare pins, then the easiest way is to use 6 pins for the switch.
With internal pull up in pinMode, and the common contact connected to ground.

I assume you know that analogue pins can also be used as digital pins.
Leo..

abuhafss:
First of all, extremely sorry. It is single-pole-six-position rotary switch for selecting permanent operating conditions.

That's ok, we all learn as we go!

By permanent, do you mean you never change switch positions while the Arduino is powered up? If so, you won't want to use the ladder resistor network when you check the switch position at start-up.

Paul

Paul_KD7HB:
By permanent, do you mean you never change switch positions while the Arduino is powered up? If so, you won't want to use the ladder resistor network when you check the switch position at start-up.

Care to explain what you mean by that?

Paul__B:
Care to explain what you mean by that?

My thought was the 5 volt supply would still be effected by the capacitors in any devices connected to the Arduino would still be drawing large charging currents, making the analog compare unstable.

Paul

Using ladder resistors works well if You measure the inputs once and use intervalls for each button.

Paul_KD7HB:
That's ok, we all learn as we go!

By permanent, do you mean you never change switch positions while the Arduino is powered up? If so, you won't want to use the ladder resistor network when you check the switch position at start-up.

Paul

The rotary switch is for selecting "Size". Once selected, we can do further steps depending upon that particular size.

At the end of those steps, the Arduino will wait for changing the rotary switch position or to switch off.

Wawa:
Depends.
Do you need all the other pins.

If you have 6 spare pins, then the easiest way is to use 6 pins for the switch.
With internal pull up in pinMode, and the common contact connected to ground.

I assume you know that analogue pins can also be used as digital pins.
Leo..

No, I have only a few digital pins left out of D2-D13 + A0-A5.

Paul_KD7HB:
My thought was the 5 volt supply would still be effected by the capacitors in any devices connected to the Arduino would still be drawing large charging currents, making the analog compare unstable.

The (default) ADC is ratiometric - that is to say it compares the analog input to the 5 V supply line.

This may sometimes be a disadvantage, but in the case of using resistor ladders as an input, this is exactly what you want as it means it is automatically compensated. :grinning: