// Define the pin for the LED
#define LED_PIN 5
#define LED_blue 4
// Define the pin for the button
#define BUTTON_PIN 6
#define buzz 8
void setup() {
// Set the LED pin as an output
pinMode(LED_PIN, OUTPUT);
pinMode(LED_blue, OUTPUT);
// Set the button pin as an input
pinMode(BUTTON_PIN, INPUT);
pinMode(buzz, OUTPUT);
}
void blink() {
digitalWrite(LED_PIN, HIGH);
digitalWrite(LED_blue, LOW);
delay(300);
digitalWrite(LED_blue, HIGH);
digitalWrite(LED_PIN, LOW);
delay(300);
}
void tetot() {
tone(buzz,300);
delay(300);
tone(buzz,200);
delay(300);
}
void loop() {
// Read the state of the button
int tombol = digitalRead(BUTTON_PIN);
// Check if the button is pressed (buttonState is LOW)
if (tombol == LOW) {
// Turn off the LED
blink();
noTone(buzz);
} else {
// Turn on the LED
digitalWrite(LED_PIN, LOW);
digitalWrite(LED_blue, LOW);
tetot();
}
}