const byte buttonPin = 2; // pin D2 --- button ---- GND
const byte relayPin = 3; // trigger pin of a suitable relay, powered separately
void lampOn() {
digitalWrite(relayPin, HIGH); // or LOW depending on the state that triggers the relay
}
void lampOff() {
digitalWrite(relayPin, LOW); // or HIGH depending on the state that release the relay
}
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
while (digitalRead(buttonPin) == LOW); // wait until button is released if needed
}
void loop() {
if (digitalRead(buttonPin) == LOW) {
// button was pressed
delay(3000); // wait for 3s (3000 ms)
lampOn(); // turn on the flash
delay(100); // for 100ms
lampOff(); // turn off the flash
while (digitalRead(buttonPin) == LOW); // wait until button is released if needed
delay(15); // poor's man anti bounce
} // end if
} // end loop