#define buzzerPin 8
#define buttonPin1 2
#define buttonPin2 3
#define buttonPin3 4
#define buttonPin4 5
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
}
void loop() {
if (digitalRead(buttonPin1) == HIGH) {
tone(buzzerPin, 262, 100); // Воспроизводим звук ноты до
} else {
noTone(buzzerPin); // Прекращаем воспроизведение звука
}
if (digitalRead(buttonPin2) == HIGH) {
tone(buzzerPin, 294, 100); // Воспроизводим звук ноты ре
} else {
noTone(buzzerPin); // Прекращаем воспроизведение звука
}
if (digitalRead(buttonPin3) == HIGH) {
tone(buzzerPin, 330, 100); // Воспроизводим звук ноты ми
} else {
noTone(buzzerPin); // Прекращаем воспроизведение звука
}
if (digitalRead(buttonPin4) == HIGH) {
tone(buzzerPin, 349, 100); // Воспроизводим звук ноты фа
} else {
noTone(buzzerPin); // Прекращаем воспроизведение звука
}
}