bool buttonOn = false;
int button = 2;
int led = 10;
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
// print to serial
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
buttonOn = digitalRead(button);
if(buttonOn){
digitalWrite(led, HIGH);
Serial.println("Button ON");
} else {
digitalWrite(led, LOW);
Serial.println("Button OFF");
}
delay(250);
}