Skip to content

Instantly share code, notes, and snippets.

@gallaugher
Last active June 6, 2018 01:05
Show Gist options
  • Save gallaugher/a31e4b59cb4f957fff5f05992bd4e375 to your computer and use it in GitHub Desktop.
Save gallaugher/a31e4b59cb4f957fff5f05992bd4e375 to your computer and use it in GitHub Desktop.
Day 12, Learning By Doing 5
byte BUTTON_PIN = 7;
byte LED_PIN = 6;
byte buttonState = 0;
void setup() {
// put your setup code here, to run once:
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(BUTTON_PIN);
Serial.print(buttonState);
if (buttonState == HIGH) {
Serial.println(" is HIGH");
digitalWrite(LED_PIN, HIGH);
} else {
Serial.println(" is LOW");
digitalWrite(LED_PIN, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment