Devices & Components
Arduino Uno Rev3
Resistor 10k ohm
Tactile Switch, Top Actuated
9V battery (generic)
Buzzer, Piezo
Solderless Breadboard Full Size
Jumper wires (generic)
Software & Tools
Arduino Web Editor
Project description
Code
Code
c_cpp
Refer to this for the CODE of MINI PIANO
1int pb1 = 2; 2int pb2 = 3; 3int pb3 = 4; 4int pb4 = 5; 5int pb5 = 6; 6int pb6 = 7; 7int pb7 = 8; 8int pb8 = 9; 9 10int buzz = 13; 11 12void setup() 13{ 14 //declare the pushbutton pins as input 15 pinMode(pb1,INPUT); 16 pinMode(pb2,INPUT); 17 pinMode(pb3,INPUT); 18 pinMode(pb4,INPUT); 19 pinMode(pb5,INPUT); 20 pinMode(pb6,INPUT); 21 pinMode(pb7,INPUT); 22 pinMode(pb8,INPUT); 23 //declare buzzer pin as output 24 pinMode(buzz,OUTPUT); 25 26} 27 28void loop() 29{ 30 // read the value from pushbuttons 31 int C = digitalRead(pb1); 32 int D = digitalRead(pb2); 33 int E = digitalRead(pb3); 34 int F = digitalRead(pb4); 35 int G = digitalRead(pb5); 36 int A = digitalRead(pb6); 37 int B = digitalRead(pb7); 38 int C2 = digitalRead(pb8); 39 40 if( C == 1 ){ 41 tone(buzz,262,100);//C,Do,sa 42 } 43 if( D == 1 ){ 44 tone(buzz,294,100);//D,Re,re 45 } 46 if( E == 1 ){ 47 tone(buzz,330,100);//E,Me,ga 48 } 49 if( F == 1 ){ 50 tone(buzz,349,100);//F,Fa,ma 51 } 52 if( G == 1 ){ 53 tone(buzz,392,100);//G,So,pa 54 } 55 if( A == 1 ){ 56 tone(buzz,440,100);//A,La,da 57 } 58 if( B == 1 ){ 59 tone(buzz,494,100);//B,Te,ni 60 } 61 if( C2 == 1 ){ 62 tone(buzz,523,100);//C,Do,sa 63 } 64 65 delay(10); 66 67 68}
Code
c_cpp
Refer to this for the CODE of MINI PIANO
1int pb1 = 2; 2int pb2 = 3; 3int pb3 = 4; 4int pb4 = 5; 5int pb5 = 6; 6int pb6 = 7; 7int pb7 = 8; 8int pb8 = 9; 9 10int buzz = 13; 11 12void setup() 13{ 14 //declare the pushbutton pins as input 15 pinMode(pb1,INPUT); 16 pinMode(pb2,INPUT); 17 pinMode(pb3,INPUT); 18 pinMode(pb4,INPUT); 19 pinMode(pb5,INPUT); 20 pinMode(pb6,INPUT); 21 pinMode(pb7,INPUT); 22 pinMode(pb8,INPUT); 23 //declare buzzer pin as output 24 pinMode(buzz,OUTPUT); 25 26} 27 28void loop() 29{ 30 // read the value from pushbuttons 31 int C = digitalRead(pb1); 32 int D = digitalRead(pb2); 33 int E = digitalRead(pb3); 34 int F = digitalRead(pb4); 35 int G = digitalRead(pb5); 36 int A = digitalRead(pb6); 37 int B = digitalRead(pb7); 38 int C2 = digitalRead(pb8); 39 40 if( C == 1 ){ 41 tone(buzz,262,100);//C,Do,sa 42 } 43 if( D == 1 ){ 44 tone(buzz,294,100);//D,Re,re 45 } 46 if( E == 1 ){ 47 tone(buzz,330,100);//E,Me,ga 48 } 49 if( F == 1 ){ 50 tone(buzz,349,100);//F,Fa,ma 51 } 52 if( G == 1 ){ 53 tone(buzz,392,100);//G,So,pa 54 } 55 if( A == 1 ){ 56 tone(buzz,440,100);//A,La,da 57 } 58 if( B == 1 ){ 59 tone(buzz,494,100);//B,Te,ni 60 } 61 if( C2 == 1 ){ 62 tone(buzz,523,100);//C,Do,sa 63 } 64 65 delay(10); 66 67 68}
Downloadable files
Circuit Diagram
Mini Piano Schematics
Circuit Diagram

Comments
Only logged in users can leave comments