int button = 27;
int LED = 14;
bool buttonState = 0; //start at off
void setup() {
//put your setup code here, to run once:
Serial.begin(115200);
pinMode(button, INPUT_PULLUP);
pinMode(LED, OUTPUT);
Serial.println();
Serial.println();
Serial.println("*** Toggle the Green button to On/Off light ***");
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(button) != 1) {
buttonState = !buttonState;
if (buttonState == 1) {
digitalWrite(LED, HIGH);
Serial.println("*** Light On ***");
} else{
digitalWrite(LED, LOW);
Serial.println("*** Light Off ***");
}
delay(100);
while (digitalRead(button) != 1){
delay (100);
}
}
}