Go Down

Topic: Library for attaching multiple buttons to a single analog input (Read 90 times) previous topic - next topic


I just completed a library that can read multiple buttons attached to a single analog pin.

Unlike the common R/2R approach, this library minimizes the number of resistors, requiring just as many resistors as the number of buttons while ensuring maximum noise immunity. This comes at the cost of having to carefully select the resistor values as documented in the code so that the voltage levels for each key are separated as much as possible, but this is readily achievable with standard resistors. (Spoiler: the code documentation includes a table with suggested resistor values.)

The library debounces the keys and optionally repeats keys that are held down.

Once initialized, reading a keypress is as simple as:

Code: [Select]
int key = your_analog_key_object;
I know there are probably several similar libraries available, but I felt like coding. :)

Find the library here: https://github.com/olewolf/Analog_Buttons.


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131