# Multiple Buttons With a Single Pin

5,492

163

13

Posted

## Introduction: Multiple Buttons With a Single Pin

Hello everyone!

A lot of us happen to end the PIN analog on our board, to avoid this you can create a circuit that depending on the voltage varies Arduino decide which button was pressed.

## Step 1: The Circuit

First we need to:

- Arduino Uno

- A resistor 4.7 KOhm

- Three resistors 1 Kohm

- Four buttons

Mounted the circuit as described in the picture or ".fzz" file.

## Step 2: The Sketch

After mounting the circuit we go to the sketch:

Code:

// Created by //
// Alessio Bigini 2015 //

void setup()

{

Serial.begin(9600); //Valore seriale

}

void loop()

{

int sensorValue = analogRead(A0); //Lettura Analogica

float voltage = sensorValue * (5.0 / 1023.0); //Conversione in Volt

Serial.println(voltage); //Stampo nel monitor seriale la tensione

}

Copied and uploaded the sketch on our board, opening the serial monitor, we can see the different voltage values depending on the button pressed.

## Step 3: Some Pictures of the Project

http://alessiobigini.it/

## Recommendations

• ### Arduino Class

67,983 Enrolled

• ### Spotless Contest

We have a be nice policy.

## Questions

great idea

To get an analog binary readout of the buttons so you can press any combination of buttons start with the lowest possible readable ohm on the resistor of the first button. Double the resistance.on the next.one and so forth. just like with binary values, every bit has the double value of the bit to the right. In theory the total measured resistance can be read as binary flags by converting the sum.of resistance to "binary". i'm sorry for my bad english. hopefully you get.the idea.

Is it anyway possible to use these buttons?

http://www.banggood.com/12V-16mm-Angel-Eye-Metal-illuminated-LED-Push-Button-Switch-Car-Dash-p-965911.html

is this limited to just the 4 buttons or is there a way to have more..

this seems simpler than what I was going to do for a keyboard attachment to an arduino.

so it would be 30 or so keys....

ahh found a easier way... use a 10 ohm resistor between each switch and you get 0 - 14 then 16 - 30 etc... up to 1023....

so the wiring is on + side between each switch is the 10 ohm resistor and the - side is a common wire here is the picture...

same code as above...

We used to see a very similar use in very old VCR units with wired remotes. A common failure was the switches developing contact resistance which would cause the play button to act as stop etc.. This circuit would allow the use of a two wire multi-button remote control.

I am considering building a collection of instructables on beginning Arduino.

Do I have your permission to include this instructable?

Yes

It's added to mt collection, I'll let you know when I publish it.

I thought of doing this one myself, but you beat me to it.

This is one of those rare ideas that utterly shocked me in its simplicity and usefulness. Great work!