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

Multiple buttons with a single pin

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.

Multiple buttons with a single pin
Multiple_Buttons.fzz5 KB

Step 2: The sketch

Multiple buttons with a single pin

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.

Multiple buttons with a single pin
Multiple_Buttons.ino395 bytes

Step 3: Some pictures of the project

Multiple buttons with a single pin
Multiple buttons with a single pin
Multiple buttons with a single pin

For more info visit:

http://alessiobigini.it/

 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel