#define GREEN_BUTTON_PIN 25
#define BUZZER_PIN 15
#define GREEN_LED_PIN 17
// Define yellow button pin and set the value 26
#define YELLOW_BUTTON_PIN 26
// Define the YELLOW_LED_PIN and set the value 16
#define YELLOW_LED_PIN 16
void setup() {
Serial.begin(115200);
pinMode(GREEN_BUTTON_PIN, INPUT_PULLUP);
// Use internal pull-up resistor for the button
pinMode(YELLOW_BUTTON_PIN, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
// Set the YELLOW_LED_PIN as OUTPUT
pinMode(YELLOW_LED_PIN, OUTPUT);
}
void loop() {
int greenButtonState = digitalRead(GREEN_BUTTON_PIN);
// Read the yellow button state
int yellowButtonState = digitalRead(YELLOW_BUTTON_PIN);
if (greenButtonState == LOW) {
tone(BUZZER_PIN, 4000);
digitalWrite(GREEN_LED_PIN, HIGH);
delay(1000);
tone(BUZZER_PIN, 0);
digitalWrite(GREEN_LED_PIN, LOW);
delay(500);
}
// Write condition to handle yellow button pressed
if (yellowButtonState == LOW) {
tone(BUZZER_PIN, 4500);
digitalWrite(YELLOW_LED_PIN, HIGH);
delay(1000);
tone(BUZZER_PIN, 0);
digitalWrite(YELLOW_LED_PIN, LOW);
delay(500);
}
}