Multiple Buttons using one Analog Read

From CunningWiki
Jump to: navigation, search

So here is the dilemma. You are running out of digital input pins but you still need to add six buttons. Fortunately there is a way you can add all these digital inputs as long as you have an analog pin. What you need to do is wire all the buttons and connect it to a R-2R Ladder. A R-2R Ladder is a very simple Digital to Analog converter. You treat your buttons as if they were bits and you use an analog pin on a microcontroller to read them.

In practice the accuracy of an R-2R ladder becomes more poor as more bits are added. Most hobbiest do not go over 5 bits since the required tolerance of the resistors need to be less than 1% beyond that.


Lets say you have a 10bit A/D converter on your 5V micro controller. 2^10 = 1024 steps so that would mean you can resolve 5V into 1024 parts. 5V/1024 = 0.00488V or 4.88mV.


If you mapped these buttons to act as bits in R2 ladder the following would be true.

2^6 = 64 steps 5V / 64 steps = 0.078125V or 78mV/step

Schematic exmaple of 7 bit R-2R
N Channel NOR