Skip to content

Using a library with analog pins

Vladimír Záhradník edited this page Aug 16, 2020 · 2 revisions

If your project does not allow you to connect buttons to digital inputs (which is preferred), you can use analog inputs to which multiple buttons/switches can be connected. However, this has one limitation - the user can press only one button at a time (simultaneous pressing of numerous buttons is not supported, unlike digital pins).

Wiring example

The basic idea of using an analog pin is simple. When the user presses the button, the voltage on the analog input will change to the specific (unique) value; for example, when pressing button S1, the input voltage will be 1 V; when pressing button S2, the output will be 2 V, etc. Change of the input voltage is achieved buttons to voltage divider:

schematics

Clone this wiki locally