How To Connect Multiple Buttons with MCU Using One Line

How To Connect Multiple Buttons with MCU Using One Line


One of the biggest problems you could face in your current/next project, is when you’re out of free inputs to use.
Sometimes you can save a lot of inputs using some tricks, and there’re really a lot of them.
In this blog post we’re going to know how you can use many push buttons using only one analog input pin. John Boxall from demonstrates how we can do that.

Almost all MCUs come with an ADC unit, which is responsible to convert the voltage from an analog value to a digital one (digitizing), for example Arduino UNO, which uses Atmega328 MCU, has an 8-bit ADC.

ADCs convert the voltage to a number (level), so a 8-bit resolution ADC converts Vin to 256 levels.
By using this fact, we can build a voltage divider using a resistor for each button, using one ADC line and recognize each button.

John used Arduino UNO to implement this hack. He used one of the ADC lines, enabled its internal pull-up resistor and connected the buttons and resistors to it, as shown in the following diagram.

Images courtesy of tronixstuff

So now every button has a unique ADC value as the following:

  • 1023 for nothing pressed (default state).
  • 454 for button one.
  • 382 for button two.
  • 291 for button three.
  • 168 for button four.
  • 0 for button five.

To see the full details of this hack, and to get the source files, you can refer to tronixstuff website.



Embedded Hardware Engineer interested in open hardware and was born in the same year as Linux. Yahya is the editor-in-chief of Atadiat and believes in the importance of sharing free, practical, spam-free and high quality written content with others. His experience with Embedded Systems includes developing firmware with bare-metal C and Arduino, designing PCB&schematic and content creation.

view all posts by yahya

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.