#include <Arduino.h>
const int buttonPin1 = 2;
const int buttonPin2 = 19;
const int buttonPin3 = 18;
const int buttonPin4 = 5;
const int speakerPin = 13;
void setup() {
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buttonPin4, INPUT_PULLUP);
pinMode(speakerPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin1) == LOW) {
tone(speakerPin, 440); // Play tone 1
} else if (digitalRead(buttonPin2) == LOW) {
tone(speakerPin, 523); // Play tone 2
} else if (digitalRead(buttonPin3) == LOW) {
tone(speakerPin, 659); // Play tone 3
} else if (digitalRead(buttonPin4) == LOW) {
tone(speakerPin, 784); // Play tone 4
} else {
noTone(speakerPin); // Stop the tone when no button is pressed
}
}