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:
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.
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)
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.
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.
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?
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.
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.