Add a second LED to the example on the previous page. This second LED should blink when the button is pushed. The first LED should blink when the button is released.
Control program :
const int pinPushbutton = 3; // we define the pins
const int pinLED = 13;
int pushbuttonOn; // variable that stores the state of the push button
void setup() {
// we configure inputs and outputs
pinMode(pinLED, OUTPUT);
pinMode(pinPushbutton, INPUT);
}
void loop(){
// we read the state of the push button
pushbuttonOn = digitalRead(pinPushbutton);
// if pressed we switch on the LED
if (pushbuttonOn == HIGH) {
digitalWrite(pinLED, HIGH);
}
else {
// if not pressed we switch it off
digitalWrite(pinLED, LOW);
}
}