Skip to content

Instantly share code, notes, and snippets.

@compilerexe
Last active October 5, 2015 14:00
Show Gist options
  • Save compilerexe/225b6578bd090f1c34bd to your computer and use it in GitHub Desktop.
Save compilerexe/225b6578bd090f1c34bd to your computer and use it in GitHub Desktop.
Read push button and show led.
int ledPin = 14;
int pushButton_Pin = 12;
int value = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(pushButton_Pin, INPUT);
}
void loop() {
value = digitalRead(pushButton_Pin);
while (value) {
value = digitalRead(pushButton_Pin);
if (value == LOW) {
digitalWrite(ledPin, 0);
Serial.println("Not Found");
} else {
digitalWrite(ledPin, 1);
Serial.println("Detect");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment