// Buzer tocando musica
int notas[ ] = {294,330,349,440,392,440,262,294,330,349,330,392,440,392,349,349,349,349,440,440,392,349,
440,440,440,392,440,392,349,349,349,349,440,440,392,349,440,440,440,554,554,554,349,349,349,440,440,392,349,
466,466,466,392,523,440,659,698,587,698,880,659,554,880,1109,1175 }; // notas musicais
int tempo[ ] = {600,300,600,300,300,300,600,600,300,300,300,300,300,300,300,150,150,150,150,150,150,300,
150,150,150,150,150,150,300,150,150,150,150,150,150,300,150,150,300,150,150,300,150,150,150,150,150,150,300,
150,150,150,300,300,300,300, 75, 75, 75, 75, 75, 75, 75, 75,1200 }; // duração das notas musicais
int pausa[ ] = { 300, 0 ,600,150,150, 0, 600,300, 0, 300,300,300,300,300,600,150,150,150,150,150,150,300,150, 150,150,150,150,150,300,150,150,150,150,150,150,300,150,150,300,150,150,300,150,150,150,150,150,150,300,150,150,150,300,300,300,300, 75, 75, 75, 75, 75, 75, 75, 75, 1200 }; // duração das pausas entre as notas
int BUZZER = 8;
int BOT = 2;
int LED = 10;
void setup( ) {
pinMode(BUZZER, OUTPUT);
pinMode(BOT, INPUT);
pinMode(LED, OUTPUT);
}
void loop( ) {
if(digitalRead(BOT) == HIGH) {
for(int i = 0; i <= 64; i++) {
tone(BUZZER, notas[i]);
digitalWrite(LED, HIGH);
delay(tempo[i]);
noTone(BUZZER);
digitalWrite(LED, LOW);
delay(pausa[i]);
}
}
}