#define BUZZER_PIN 2 // Conectar el buzzer al pin 2
unsigned int melody[] = {
262, 196, 196, 220, 196, 247, 262, 262, 196, 196, 220, 196, 262, 247
};
// Duración de cada nota (en milisegundos)
unsigned int noteDurations[] = {
300, 150, 150, 300, 300, 300, 300, 300, 150, 150, 300, 300, 300, 300
};
void setup() {
for (int i = 0; i < 8; i++) {
tone(BUZZER_PIN, melody[i], noteDurations[i]); // Reproduce la nota
delay(noteDurations[i] + 50); // Espera
}
noTone(BUZZER_PIN); // Se apaga el buzzer
}
void loop() {
// put your main code here, to run repeatedly:
}