Created
May 14, 2017 12:40
-
-
Save prasant1010/5694cd6a6ba154ee666b904add048642 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
created by prasant | |
www.electronify.org | |
you can do what ever you want with this piece of code | |
*/ | |
const int buttonPin1 = 14; // the number of the pushbutton pin | |
const int buttonPin2 = 15; | |
const int buttonPin3 = 16; | |
int buttonState1 = 0; // variable for reading the pushbutton status | |
int buttonState2 = 0; | |
int buttonState3 = 0; | |
void setup(){ | |
pinMode(buttonPin1, INPUT); | |
pinMode(buttonPin2, INPUT); | |
pinMode(buttonPin3, INPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
// read the state of the pushbutton value: | |
buttonState1 = digitalRead(buttonPin1); | |
buttonState2=digitalRead(buttonPin2); | |
buttonState3=digitalRead(buttonPin3); | |
// check if the pushbutton is pressed. | |
// if it is, the buttonState is HIGH: | |
if (buttonState1 == HIGH) { | |
Serial.write(1); | |
} | |
else if (buttonState2 == HIGH) { | |
Serial.write(2); | |
} | |
else if (buttonState3 == HIGH) { | |
Serial.write(3); | |
} | |
else{ | |
Serial.write(4); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment