const int PinLed = 8; // define constant PinLed
bool pinOn = false; // define true/false boolean variable
// and initialize to false
void setup() {
Serial.begin(115200); // set serial interface speed
pinMode (PinLed, OUTPUT); // configure pin
}
void loop() {
if (pinOn) { // execute code w/in braces if pinOn is true
digitalWrite (PinLed, LOW); // turn off
pinOn = false;
}
else { // otherwise execute this block of code
digitalWrite (PinLed, HIGH); // turn on
pinOn = true;
}
delay (500); // delay half second
}