loading

What you need:

13 long wires

8 short wires

1 Piezo Buzzer

8 330 ohm Resistors

8 Buttons

1 Arduino

1 USB Cord

2 Breadboards

Wood

Wood Glue

Wood Tools

Step 1: Part 1: Making the Box

In order for this project to be successful, the piano should have a cover, such as every piano ever. We decided to make our cover out of wood, but you could use any type of material you like.

Step 2: Part 1; Step 1: Measuring the Dimensions

The dimensions of our Arduino piano were 7.5 by 5 inches, and we also used a 3 inch partial covering on the top so that the keys would remain useable. So by using these dimensions, we cut a piece of quarter inch wood into 5 pieces, 2 of which have the dimensions of 7.5 by 5 inches, 2 others have the dimensions of roughly 5 by 6 inches, and the partial top has the dimension of 7.5 by 3 inches.

Step 3: Part 1, Step 2: Putting the Wood Together

Make sure you have wood glue so you can put the cover together in order to form the box as displayed in the picture above. (The 7.5 by 5 inch pieces will go on the bottom and in the back; the 5 by 6 inch pieces will go on the vertical sides; and the 7.5 by 3 inch piece will go on the top.) Make sure you drill a 9/16 inch hole in one of the vertical side (5x6 inch) pieces in order to connect the USB chord to the piano.

Step 4: Part 1; Step 3: Decorations

After the box is put together, you might want to consider decorating your box to make your piano look nicer. We used wood stain to darken the wood; which in our opinion makes our project look worthwhile! You could use anything though, make your piano cover your own!

Step 5: Part 2: the Arduino Portion

Now that we've talked about the outside of the piano, let's talk about the nitty gritty. Let's create the programming and the keyboard that will ultimately create our Arduino piano!

Step 6: Part 2: Step 1:The Code

First of all, let's get the code you will need to enter into your computer in order to get your piano working. The code you will need to enter into the Arduino app is below for you to use.

int button_C = 2;

int button_D = 3; int button_E = 4; int button_F = 5; int button_G = 6; int button_A = 7; int button_B = 8; int button_Cup = 9;

int speaker = 13;

int buttonstate_C = 0; int buttonstate_D = 0; int buttonstate_E = 0; int buttonstate_F = 0; int buttonstate_G = 0; int buttonstate_A = 0; int buttonstate_B = 0; int buttonstate_Cup = 0;

//NOTES 'c' , 'd', 'e', 'f', 'g', 'a', 'b', 'C' int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; //freq int Cur_tone = 0;

void setup() { pinMode(button_C, INPUT); pinMode(button_D, INPUT); pinMode(button_E, INPUT); pinMode(button_F, INPUT); pinMode(button_G, INPUT); pinMode(button_A, INPUT); pinMode(button_B, INPUT); pinMode(button_Cup, INPUT);

pinMode(speaker, OUTPUT); }

void loop() { buttonstate_C = digitalRead(button_C); buttonstate_D = digitalRead(button_D); buttonstate_E = digitalRead(button_E); buttonstate_F = digitalRead(button_F); buttonstate_G = digitalRead(button_G); buttonstate_A = digitalRead(button_A); buttonstate_B = digitalRead(button_B); buttonstate_Cup = digitalRead(button_Cup);

if((buttonstate_C == HIGH) || (buttonstate_E == HIGH) || (buttonstate_G == HIGH) || (buttonstate_D == HIGH) || (buttonstate_F == HIGH) || (buttonstate_A == HIGH) || (buttonstate_B == HIGH) || (buttonstate_Cup == HIGH) ) { if (buttonstate_C == HIGH) { Cur_tone = tones[0]; } if (buttonstate_E == HIGH) { Cur_tone = tones[1]; } if (buttonstate_G == HIGH) { Cur_tone = tones[2]; } if (buttonstate_D == HIGH) { Cur_tone = tones[3]; } if (buttonstate_F == HIGH) { Cur_tone = tones[4]; } if (buttonstate_A == HIGH) { Cur_tone = tones[5]; } if (buttonstate_B == HIGH) { Cur_tone = tones[6]; } if (buttonstate_Cup == HIGH) { Cur_tone = tones[7]; }

digitalWrite(speaker, HIGH); delayMicroseconds(Cur_tone); digitalWrite(speaker, LOW); delayMicroseconds(Cur_tone); } else //in case no button is pressed , close the piezo { digitalWrite(speaker, LOW); }

}

Step 7: Part 2, Step 2: the Breadboard

In order to properly construct an Arduino piano, it is necessary to properly wire the two breadboards to the central Arduino Uno. Each button, functioning as a piano key, must be properly wired to the Arduino in order to supply power and transfer information from the code. There are eight wires designated for this purpose: A wire connected from A26 on the breadboard to 2 on the Arduino, A21 to 3, A16 to 4, A11 to 5, and A4 to 6 on the first (or left) breadboard, and A28 to 7, A23 to 8, and A18 to 9 on the second breadboard. There are three more wires needed for the proper distribution of power and charge, those being a wire connecting F6 to 13, a wire connecting the last (rightmost) positive row to SV and the last negative row (not directly below the positive) to GND, all on the second breadboard. There are also two wires which connect the two breadboards, allowing for the transfer of charge. These are two wires connecting the last positive and negative strips on the left breadboard to the second to last positive and negative strips on the right breadboard.

In addition to the long wires, there are shorter wires that need to be used in order to manage the charge of the buttons. These are placed as follows: J28 is connected to the first positive grid (+), J23 to second (+), J18 to third (+), J13 to fourth (+), and J6 to fifth (+) on the first breadboard, and J30 to first (+), J25 to second (+), and J20 to third (+) on the second breadboard.

330 ohm resistors must be placed alongside these wires in order to ensure the power transfer to the buttons is managed effectively. The resistors will be placed in these locations: J26 to the first negative patch (-), J21 to second (-), J16 to third (-), J11 to fourth (-), J4 to fifth (-) on the breadboard, and J28 to first (-), J23 to second (-), and J18 to third (-).

The buttons occupy four spaces in the grid each, so their locations will be provided in a coordinate format: On the first breadboard, they will be located on (D28, D26, G28, G26), (D23, D21, G23, G21), (D18, D16, G18, G16), (D13, D11, G13, G11), and (D6, D4, G6, G4). On the second breadboard, they are located on (D30, D28, G30, G28), (D25, D23, G25, G23), and (D20, D18, G20, G18). The piezo speaker will be placed on J6 and will connect to the last negative strip on the right breadboard.

Step 8: Part 2, Step 3: Connecting

All you need to do now is connect the Arduino breadboards to your laptop/power source and your piano should begin working. If you have issues, check your wiring and coding for potential issues. Have fun with this project, and see what you can create!

<p>Very cool idea. Thanks for sharing!</p>

About This Instructable

395views

4favorites

License:

More by SidM7:How to Make an Arduino Piano  
Add instructable to: