Multiple Buttons With a Single Pin

by dev.alessiobigini in Circuits > Arduino

7429 Views, 164 Favorites, 0 Comments

Multiple Buttons With a Single Pin

11042161_729356647162291_231646418_n.jpg

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.

The Circuit

Cattura-di-schermata-14.png

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.

The Sketch

Cattura-di-schermata-13.png

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.

Some Pictures of the Project

11023165_729356677162288_574699871_n.jpg
11040671_729356657162290_871425079_n (1).jpg
10816066_729356667162289_555893716_n.jpg

For more info visit:

http://alessiobigini.it/