Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasant1010/5694cd6a6ba154ee666b904add048642 to your computer and use it in GitHub Desktop.
Save prasant1010/5694cd6a6ba154ee666b904add048642 to your computer and use it in GitHub Desktop.
/*
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