
El Código
//---------------------------------------------------------------
int Boton1 = 2;
int Boton2 = 3;
int Boton3 = 4;
int Boton4 = 5;
int Boton5 = 7;
int Boton6 = 8;
int Boton7 = 9;
//---------------------------------------------------------------
int Buzzer = 6;
//---------------------------------------------------------------
void setup()
//---------------------------------------------------------------
{
//---------------------------------------------------------------
pinMode(Boton1, INPUT_PULLUP);
pinMode(Boton2, INPUT_PULLUP);
pinMode(Boton3, INPUT_PULLUP);
pinMode(Boton4, INPUT_PULLUP);
pinMode(Boton5, INPUT_PULLUP);
pinMode(Boton6, INPUT_PULLUP);
pinMode(Boton7, INPUT_PULLUP);
//---------------------------------------------------------------
pinMode(Buzzer, OUTPUT);
//---------------------------------------------------------------
}
//---------------------------------------------------------------
void loop()
{
//---------------------------------------------------------------
int Valor7 = digitalRead(Boton1) ;
int Valor6 = digitalRead(Boton2) ;
int Valor5 = digitalRead(Boton3) ;
int Valor4 = digitalRead(Boton4) ;
int Valor3 = digitalRead(Boton5) ;
int Valor2 = digitalRead(Boton6) ;
int Valor1 = digitalRead(Boton7) ;
//---------------------------------------------------------------
if (Valor1==LOW && Valor2==LOW && Valor3==LOW && Valor4==LOW && Valor5==LOW && Valor6==LOW && Valor7==LOW){ noTone(Buzzer); }
//---------------------------------------------------------------
if (Valor7==HIGH){ tone(Buzzer, 493.88); }
if (Valor6==HIGH){ tone(Buzzer, 440); }
if (Valor5==HIGH){ tone(Buzzer, 392); }
if (Valor4==HIGH){ tone(Buzzer, 349.23); }
if (Valor3==HIGH){ tone(Buzzer, 329.63); }
if (Valor2==HIGH){ tone(Buzzer, 293.66); }
if (Valor1==HIGH){ tone(Buzzer, 261.63); }
//---------------------------------------------------------------
}
Piano, Versión 1
Piano Interactivo. Básico:​
Materiales para el proyecto:
​
Arduino Uno.
1 Buzzer.
7 Pulsadores.
7 Resistencias de 10 K ohm.
Conexión:
​
​Pin 6 del Arduino al Buzzer.
​Pin 2 del Arduino al Pulsador 1.
​Pin 3 del Arduino al Pulsador 2.
​Pin 4 del Arduino al Pulsador 3.
​Pin 5 del Arduino al Pulsador 4.
​Pin 7 del Arduino al Pulsador 5.
​Pin 8 del Arduino al Pulsador 6.
​Pin 9 del Arduino al Pulsador 7.
​
















