int BUZZER_PIN = 13;
int BUZZER_CHANNEL = 0;
int b1,b2,b3,b4;
void setup() {
pinMode(5,INPUT_PULLUP);
pinMode(18,INPUT_PULLUP);
pinMode(19,INPUT_PULLUP);
pinMode(2,INPUT_PULLUP);
ledcAttachPin(BUZZER_PIN, BUZZER_CHANNEL);
}
void loop() {
b1 = digitalRead(5);
b2 = digitalRead(18);
b3 = digitalRead(19);
b4 = digitalRead(2);
if (b1== LOW)
{
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_D, 8);
delay(10);
}
else if (b2== LOW)
{
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_A, 8);
delay(10);
}
else if (b3== LOW)
{
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_G, 8);
delay(10);
}
else if (b4== LOW)
{
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_A, 4);
delay(150);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_B, 5);
delay(20);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_C, 5);
delay(20);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_D, 5);
delay(20);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_E, 5);
delay(20);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_A, 3);
delay(30);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_C, 5);
delay(20);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_C, 6);
delay(20);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_F, 5);
delay(30);
ledcWriteNote(BUZZER_CHANNEL, (note_t)NOTE_G, 5);
delay(20);
}
else
{
ledcWrite(0, 0);
delay(10);
}
}