int ledPin = 13; //Assigns the variable to pin 13
int buttonPin = 2; //Assigns the variable to pin 2
int buttonState = 0; //off
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) { //The button when pressed
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
}