Skip to content

Instantly share code, notes, and snippets.

@samilkorkmaz
Last active February 8, 2020 19:01
Show Gist options
  • Save samilkorkmaz/8a92ccbc7aea4c89c6a4dd53a1835f1b to your computer and use it in GitHub Desktop.
Save samilkorkmaz/8a92ccbc7aea4c89c6a4dd53a1835f1b to your computer and use it in GitHub Desktop.
Button + external LED with Arduino Nano
#define buttonPin 4
#define extLEDPin 8
void setup(){
Serial.begin(9600);
Serial.println("--- Hello :) ---");
pinMode(buttonPin, INPUT);
pinMode(extLEDPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
Serial.println("LED HIGH");
digitalWrite(extLEDPin, HIGH);
} else {
Serial.println("LED LOW");
digitalWrite(extLEDPin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment