// Define the pins to be used const int pinLED = 0; // Pin where the LED is connected const int pinSwitch = 29; // Pin where the switch is connected void setup() { // Configure the LED pin as output pinMode(pinLED, OUTPUT); // Configure the switch pin as input with pull-up pinMode(pinSwitch, INPUT_PULLUP); } void loop() { // Read the state of the switch int switchState = digitalRead(pinSwitch); // If the switch is pressed (LOW state) if (switchState == LOW) { // Turn on the LED digitalWrite(pinLED, HIGH); // Perform three flashes for (int i = 0; i < 3; i++) { digitalWrite(pinLED, HIGH); delay(500); // Turn on the LED for 500 ms digitalWrite(pinLED, LOW); delay(500); // Turn off the LED for 500 ms } // Turn off the LED digitalWrite(pinLED, LOW); // Wait until the switch is released while (digitalRead(pinSwitch) == LOW) {} } }