//declare variables
const int LED = 16;
const int SW = 17;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(LED,OUTPUT);
pinMode(SW,INPUT_PULLUP); //Input PULL_UP initial
digitalWrite(LED,LOW);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
while(digitalRead(SW)==LOW) // check SWITCH
{
digitalWrite(LED,HIGH);
Serial.print("LED ON, SWITCH IS PRESSED");
Serial.println();
delay(1000);
}
digitalWrite(LED,LOW);
Serial.print("LED OFF, PRESS SWITCH TO TURN ON THE LED");
Serial.println();
delay(10); // this speeds up the simulation
}