Differences

This shows you the differences between two versions of the page.

Link to this comparison view

arduino_boards:multiplex_switches [2020/03/30 22:55]
admin [Mapping Problem]
arduino_boards:multiplex_switches [2020/06/11 22:13]
Line 1: Line 1:
-===== Multiplex Switches with one Analog Input ===== 
  
-{{:​arduino_boards:​multiplex_switch.jpg?​600|}}\\ 
- 
-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 [[https://​www.arduino.cc/​reference/​en/​language/​functions/​math/​map/​|map]] and the [[https://​www.arduino.cc/​reference/​en/​language/​structure/​control-structure/​switchcase/​|switch...case]] function to detect the switch position. And additional multi-switch detection is super easy, too. 
- 
----- 
-==== Paper PCB ==== 
-{{:​arduino_boards:​multiplexed-buttons_11.jpg?​400|}}\\ 
-{{ :​arduino_boards:​multiplexed-buttons_11.zip |}}\\ 
- 
----- 
-==== Code ==== 
-{{ :​arduino_boards:​multiplex_button_02.zip |}} 
- 
- 
----- 
-==== Mapping Problem ==== 
- 
-Unfortunately the map function didn't spread the mapped numbers even. Just the last number is assigned to the last mapping number. All the others are equally mapped.\\ 
-[[https://​www.best-microcontroller-projects.com/​arduino-map.html]] 
- 
-To spread the results equally ​ from 0 to 15 I used in the code the mapping function like that: 
-   ​map(my_value,​ -30, 981, 0, 16) 
- 
-----