Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: yakumoklesk on Feb 07, 2018, 12:58 pm

Title: Multiple position switch (either rotary, toggle, etc.)
Post by: yakumoklesk on Feb 07, 2018, 12:58 pm
Hi, I would need a switch that provides multiple positions, but that outputs an PWM value that can be read just by using only one pin of the Arduino.
I've seen this:
https://www.dfrobot.com/wiki/index.php/Rotary_Switch_Module_V1_(SKU:SEN0156) (https://www.dfrobot.com/wiki/index.php/Rotary_Switch_Module_V1_(SKU:SEN0156))

The problem is that the shipping costs is higher than the price of the swith itself. I would like to know if there is any alternative that can be send with lower shipping costs or even free like some things on AliExpress.

I've found many rotary switches, that have multiple outpus, but I don't se those output pins fitting on a breadborad, nor I have no idea of how converting so many pins into just only one, although I've read that resistors need to be used for that.
I would appreciate any help that you could give to me.

My project is just as simple as use the switch to select a different song to play every time. Is something I want to show to my toddler.

Thanks in advance.
Title: Re: Multiple position switch (either rotary, toggle, etc.)
Post by: Grumpy_Mike on Feb 07, 2018, 01:42 pm
How about this:-
12 position rotary switch (https://uk.rs-online.com/web/p/products/0320180/?grossPrice=Y&cm_mmc=UK-PLA-DS3A-_-google-_-PLA_UK_EN_Switches-_-Rotary_Switches_And_Accessories%7CRotary_Switches-_-PRODUCT+GROUP&matchtype=&gclid=CjwKCAiA5OrTBRBlEiwAXXhT6DEnvf66J75hTQvnH_cKDqULaGYIubeFjGMQcozMHqLdBY0xu0AuBhoCt78QAvD_BwE&gclsrc=aw.ds)

Quote
I've found many rotary switches, that have multiple outpus, but I don't se those output pins fitting on a breadborad,
So don't use a breadboard, hateful unreliable things anyway.


Quote
nor I have no idea of how converting so many pins into just only one,
Use the circuit on the right and just add more resistors.
(https://forum.arduino.cc/index.php?action=dlattach;topic=527409.0;attach=244422)
Title: Re: Multiple position switch (either rotary, toggle, etc.)
Post by: yakumoklesk on Feb 10, 2018, 04:23 pm
Thanks for your answer. I've seen in this page http://simvim.com/arduino/in_analog.html (http://simvim.com/arduino/in_analog.html) that the guy also uses a capacitor. I was wondering why some diagrams I've seen introduces a capacitor and others don't. Is there any real danger of a peak voltage in a circuit like this?

Thanks.

David.
Title: Re: Multiple position switch (either rotary, toggle, etc.)
Post by: PaulRB on Feb 10, 2018, 07:58 pm
If by "peak voltage" you mean a voltage spike, no. The cap is probably just for debouncing, and could be done in software instead. The rotary switch probably has "break-before-make" contacts, so there will be short periods where the analog input is floating and could read anything from 0 to 1023 for a reading or two. If your code checks that the reading is stable before acting on any change, you can probably dispense with the cap.
Title: Re: Multiple position switch (either rotary, toggle, etc.)
Post by: yakumoklesk on Feb 10, 2018, 10:00 pm
Yes, I wanted to say voltage spike, thanks for the clarification. Also thank you for the explanation, it helps me understand more. Now I understand why a cap is not needed when using an array of buttons.

Regards,

David.