How to work with this Rotary switch (12 positions) ? help !

hello guys,
i hope you all having a good day,
well i need help please for a good tutorial on how to use the 12 positions rotary switch in the picture below with arduino uno ? so far i haven't been lucky :confused:

rotary switch.jpg

I would suspect it has 4 commons to select one of three pins.

Please let is know how the switch turns, how many clicks?

Get a multimeter and work out what connections are made when you turn it.

Weedpharma

weedpharma:
I would suspect it has 4 commons to select one of three pins.

It looks like it is a 12-position switch with the common near the centre.

yes guys, it's a 12 positions means 11 clicks, the center pin is the common
i am making some research still so i found this post about 3 positions in which Grumpy Mike suggested to connect resistors and the common to analog of arduino, i guess i can use the same logic for my 12 positions, in which i connect 1K resistor between every 2 pins and pin 1 will go to ground and pin 12 to +5 and after i start selecting, the first pin will give me 0 and last pin will give me +5, do you think this method would work ?

http://forum.arduino.cc/index.php?topic=138449.15

firashelou:
I am making some research still so i found this post about 3 positions in which Grumpy Mike suggested to connect resistors and the common to analog of arduino, i guess i can use the same logic for my 12 positions, in which i connect 1K resistor between every 2 pins and pin 1 will go to ground and pin 12 to +5 and after i start selecting, the first pin will give me 0 and last pin will give me +5, do you think this method would work ?

Yes that should work.

Your switch is probably break-before-make which means there will be a few miliseconds during each click when the input to your Arduino will be open-circuit.

Hi,
That switch if you look should have molded into the white back, 1 to 12 etc.
12 positions, 11 clicks.
The centre pin (A) is the switched wiper.

Tom.... :slight_smile:

Better look and further information and I agree it has 1 common (it looked like 4 pins in centre but I agree there is one).

What do your want to do with it?

Weedpharma

Looks similar to these switches Tayda sells...

Hi,
All come from the same factory in Asia, just specify solder tags or through hole.
They have a stop washer so you can setup any number of positions.

Tom.... :slight_smile:

Here is a quick way to use this switch. Obviously this is a voltage divider and you need to use an analog input. Calculate the voltage for each node and determine the approximate analogread value for it. For example, in switch position 1, 4700/1000 gives a ratio of 1000/(1000+4700) = .175. .1751023 will make for an analogread value of about 179. In switch position 2, 4700/1200 gives a ratio of 1200/(1200+4700) = .203. .2031023 will make for an analogread value of about 207. All the other switch positions can be calculated out this way or you can just set each position and hit it with a multimeter.

http://www.raltron.com/cust/tools/voltage_divider.asp

weedpharma:
Better look and further information and I agree it has 1 common (it looked like 4 pins in centre but I agree there is one).

What do your want to do with it?

Weedpharma

yes right it has 1 common this rotary switch
well i want to use 4 of these, 1 of these will be a menu, means when i click position 1 it will give me the temperature lets say, if 2 it will display something else and so on ...

JoeN thanks for that :slight_smile:
and thanks everyone for the help i appreciate it, i will start to experiment with it like you told me and if i got a problem during the process i will get back :slight_smile:

firashelou:
JoeN thanks for that :slight_smile:
and thanks everyone for the help i appreciate it, i will start to experiment with it like you told me and if i got a problem during the process i will get back :slight_smile:

Look again. I simplified the math a bit because the voltage itself isn't relevant, only the ratio. I gave a second example. Hopefully it is even clearer now.

JoeN:
Here is a quick way to use this switch.
...

Probably a lot easier to just use the same resistor value for all:

Ah, nice. Did not think of that. Use 1Ks all around.

thanks Paul yes that's what i meant, so the voltage will be divided between 2 pins right ? and each pin will give a different value because the it might have 2 resistors before means 1 + 1 = 2K for example

firashelou:
thanks Paul yes that's what i meant, so the voltage will be divided between 2 pins right ? and each pin will give a different value because the it might have 2 resistors before means 1 + 1 = 2K for example

The voltage at the first position is zero since there is a low impedance path to ground and will have an analogread of 0. The voltage at the last position is the high rail for the same reason, analogread of 1023. Since resistors in series simply add, the voltage at the second position (assume 12 positions and not 9 and all values the same) is 1 vs 10, so 1/(10+1)= 0.09, or an analog read of 93. The voltage at the third position is 2 vs 9, so 2/(9+2) = 0.18, or an analog read of 186. Eleventh position is 10 vs 1 so (10/10+1) = .91, analogread is 930. This works for any value resistor, though you probably want 1K or so to limit current drain. Higher is better but if you go too high then noise becomes a factor. No idea how high is too high, 1K sounds good to me.

But you can always just set the 12 switch positions and read it out with a multimeter too.

The advantage of equal values is that you do a simple (integer) division of the analog reading to obtain an integer value corresponding to the switch position.

JoeN:
The voltage at the first position is zero since there is a low impedance path to ground and will have an analogread of 0. The voltage at the last position is the high rail for the same reason, analogread of 1023. Since resistors in series simply add, the voltage at the second position (assume 12 positions and not 9 and all values the same) is 1 vs 10, so 1/(10+1)= 0.09, or an analog read of 93. The voltage at the third position is 2 vs 9, so 2/(9+2) = 0.18, or an analog read of 186. Eleventh position is 10 vs 1 so (10/10+1) = .91, analogread is 930. This works for any value resistor, though you probably want 1K or so to limit current drain. Higher is better but if you go too high then noise becomes a factor. No idea how high is too high, 1K sounds good to me.

But you can always just set the 12 switch positions and read it out with a multimeter too.

i got a little bit confused here :frowning:
what do u mean here 10 vs 1, 9 vs 2

Paul__B:
The advantage of equal values is that you do a simple (integer) division of the analog reading to obtain an integer value corresponding to the switch position.

The digital reading of the first switch position should be 0, the second position should be 93 and the third position should be 186 etc. So integer division by 93 would give you the switch position. However if one digital reading is slightly lower than it should be due to noise or resistor value tolerances, say it is 185, then you would get the wrong result by doing only integer division. Better to add 47 before integer division by 93.