const int buttonPin = 2;
const int ledPin = 13;
void setup() {
//enable pull-up resistor
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
int buttonVal = digitalRead(buttonPin);
if (buttonVal == HIGH) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
delay(100);
}