This is an old revision of the document!


Multiplex Switches with one Analog Input

With an simple R-2R ladder one can build an easy multiple switch detection for an Arduino with just one analog input. That way one needs maybe some more components than in a simple resistor network but on the other hand one can just use the simple map and the switch...case function to detect the switch position. And additional multi-switch detection is super easy, too.


Paper PCB


Mapping Problem

Unfortunately the map function didn't spread the mapped numbers even. Just the last, one or two, numbers are assigned to the last number to map. All the others are equally mapped.
https://www.best-microcontroller-projects.com/arduino-map.html

In the code I used a map function like that:

 map(my_value, -30, 981, 0, 16)

That will spread the results equally.