// Frecuencias (Hz) - Cuarta octava
const int Do = 262;
const int Re = 294;
const int Mi = 330;
const int Fa = 349;
const int Sol = 392;
const int La = 440;
const int Si = 494;
// Pines de conexión
const int BOTON_do = 7;
const int BOTON_re = 6;
const int BOTON_mi = 5;
const int BOTON_fa = 4;
const int BOTON_sol = 3;
const int BOTON_la = 2;
const int BOTON_si = 1;
const int PIEZO = 13;
// Notas
int nota[] = {Do, Re, Mi, Fa, Sol, La, Si};
// Botones
int boton[] = {BOTON_do, BOTON_re, BOTON_mi, BOTON_fa, BOTON_sol, BOTON_la, BOTON_si};
void
setup() {
for (int i = 0; i < 7; i++) {
pinMode(boton[i], INPUT);
}
pinMode(PIEZO, OUTPUT);
}
void loop() {
for (int i = 0; i < 7; i++) {
while (digitalRead(boton[i]) == HIGH) {
tone(PIEZO, nota[i]);
}
}
noTone(PIEZO);
}