Multiple Buttons using one Analog Read

From CunningWiki
Revision as of 21:16, 11 July 2011 by Dye (Talk | contribs) (Created page with "So here is the dilemma. You ran out of digital input pins but you still need to add seven buttons. Fortunately there is a way you can add all these digital inputs as long as you ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

So here is the dilemma. You ran out of digital input pins but you still need to add seven 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 in a resistor ladder and form a Digital to Analog converter.


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^7 = 128 steps 5V / 128 = 0.03906V or 39.06mV