Introduction: Multiple Buttons With a Single Pin

Picture of 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

Picture of The Circuit

First we need to:

- Arduino Uno

- A resistor 4.7 KOhm

- Three resistors 1 Kohm

- Four buttons

- Breadboard

- Wires for links

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

Step 2: The Sketch

Picture of The Sketch

After mounting the circuit we go to the sketch:

Code:

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

// http://alessiobigini.it //

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

Picture of Some Pictures of the Project

For more info visit:

http://alessiobigini.it/

Comments

KashifK2 (author)2017-02-04

great idea

PatricioD (author)2015-04-06

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.

tobias.sobkowiak (author)2015-03-27

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

celticht32 (author)2015-03-04

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....

celticht32 (author)celticht322015-03-05

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...

ke8bg (author)2015-03-04

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.

JRV31 (author)2015-03-03

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

Do I have your permission to include this instructable?

dev.alessiobigini (author)JRV312015-03-03

Yes

JRV31 (author)dev.alessiobigini2015-03-03

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.

Damion67 (author)2015-03-03

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

pucksurfer (author)2015-03-02

That's a brilliant idea. Never would have thought about adjusting voltage to create different buttons. I think this will come very useful as I have an UNO and I was just wondering what I was going to do for a project that I wanted to do but I would be tight on pins. This is amazing.

baudeagle (author)2015-03-02

Great idea, would it be possible to detect when multiple buttons are pushed simultaneously? I was thinking, if different valued resistors were placed between the buttons then you can determine the correct voltage drop based on the known values of the different resistors. This should enable you to detect which combination of buttons had been pressed simultaneously.

tomatoskins (author)2015-03-02

The idea of using an analog voltage to determin the button pressed is an excellent idea!

About This Instructable

5,278views

163favorites

License:

More by dev.alessiobigini:Print Flexible Filament With Creality CR-103D Printed Tunnel Carpal TutorLEDFader Arduino Library
Add instructable to: