The piano

Build your own piano by following this tutorial and learn more about the sensors along the way!


You'll need

22 wooded pieces, 1 plastic tray, 11 electronic pieces and 8 GVS cables.

Step 1

Instructions

Fit the speaker into the circular hole of the back piece. It should fit almost perfectly without falling out.




Materials

1x Back piece and 1x Speaker


Step 2

Instructions

Connect the top piece and the back piece together. The teeth of the top piece should fit nicely into the holes of the back piece.




Materials

1x Top piece


Step 3

Instructions

Insert the support piece into the small key piece.




Materials

1x Support piece and 1x small key piece


Step 4

Instructions

With the support piece attached, insert the key piece into the 2nd rectangular hole from the left of the back piece.




Materials


Step 5

Instructions

Secure the key by adjusting and inserting the support piece into the hole of the top piece.




Materials


Step 6

Instructions

Do the same with the other 2 small key pieces for the next 2 rectangular holes.




Materials

2x Support piece and 2x Small key piece


Step 7

Instructions

Repeat steps 3 to 5 with the 5 large pieces and insert them into the remaining slots of the back piece.




Materials

5x Support piece and 5x Large key piece


Step 8

Instructions

Connect 1 GVS cable to the Freaduino A0 analog pin. Make sure the colours of the GVS cable match the pin colours on the Freaduino. Put the cable through the small rectangular hole of the back piece, and through the rightmost square hole. Rest the other end of the cable on the piano key.




Materials

1x Freaduino UNO and 1x GVS Cable


Step 9

Instructions

Connect the 2nd GVS cable to the freaduino A1 analog pin. Put through the cable through the same small rectangular hole and through the 2nd rightmost square hole. Rest the end of the cable on the piano key as well.




Materials

1x GVS Cable


Step 10

Instructions

Repeat steps 8 and 9 for A2 to A5 analog pins. It is important that the wires connect to the analog pins in the same order as the square holes that they are put through.




Materials

4x GVS Cables


Step 11

Instructions

Connect 2 GVS cables into the digital pins 0 and 12 of the Freaduino. Make sure the colours match!




Materials

2x GVS Cables


Step 12

Instructions

Connect the black wire from the speaker to the GND (ground) port, and the red wire into digital port 13 of the Freaduino.




Materials


Step 13

Instructions

Thread the mini USB-Bv cable through the right piece.




Materials

1x Right piece and 1x mini USB-B Cable


Step 14

Instructions

Insert the USB cable into the USB port of the Freaduino.




Materials


Step 15

Instructions

Attach the 2 crash sensors to the GVS cables that are attached to the digital pins 0 and 12.




Materials

2x crash sensors


Step 16

Instructions

Insert the 2 crash sensors into the 2 rectangular holes of the top piece. They should fit nicely without falling out as well. The right and leftmost keys should be pressed down on the crash sensors when pressed.




Materials


Step 17

Instructions

There should be 6 GVS cables left unconnected resting on the remaining piano keys.




Materials


Step 18

Instructions

For the 3 on the right, connect a photocell to each of the cables.




Materials

3x photocells


Step 19

Instructions

For the 3 on the left, connect a moisture sensors to each of the cables.




Materials

3x moisture sensors


Step 20

Instructions

Connect a computer to the Freaduino. It should light up with a red light to denote that it is switched on.




Materials

Heres a link to the code: https://github.com/kkkgabriel/piano/blob/master/piano/piano.ino


Step 21

Instructions

Open the Arduino IDE and open a new sketch. Press Ctrl+A and del to empty the sketch.




Materials


Step 22

Instructions

This first portion is to declare the variables that we are going to need for rest of the sketch.
A variable is used to store data that can be changed during your program.
In the code (refer to image), variables declared in lines 1 to 10 are for our port and pin numbers. Variables declared in lines 12 to 20 are to store our values we get from our sensors. Notice that we do not have to store a value when we create the variable, but to use it later we have to create it first.
Variables declared in lines 22 to 24 are to store the limits that our photocells and moisture sensors have to hit to trigger any action.




Materials

Refer to "The code" under code and references of this tutorial.


Step 23

Instructions

The second portion is to set up our Arduino board. Setup() is a function which will be called once at the start, every time the Arduino starts up or resets. We have to tell the arduino which pins we are using and if they are used as output pins or input pins.




Materials

Refer to "The code" under code and references of this tutorial.


Step 24

Instructions

The next function is the piano() function. This function takes in one argument: key, which can be a number from 0 to 7. Each number would sound a different note from C4 to C5 using the tone function. The tone function is a built-in Arduino function that takes in 3 arguments – the pin number of the speaker, the frequency of the sound you want to play, and the duration of the sound. By default, this code plays notes C4 to C5. You can change the frequency of the keys to play the different notes that you want your piano to play.




Materials

Refer to "The code" under code and references of this tutorial.


Step 25

Instructions

The last portion is the loop() function which will be called repetitively after the setup() function. Every time the loop is called, we read the sensor values from all our sensors. To read our sensors, we use analogRead() for the moisture sensors and photocells as they give analog outputs, and use digitalRead() for the crash sensors as they give out digital inputs. For the crash sensors, they output 1 when the sensor is not pressed and 0 when the sensor is pressed. Thus, we put a not to reverse this reading.




Materials

Refer to "The code" under code and references of this tutorial.


Step 26

Instructions

The second part of the loop() function is the control flow, where we check if any of the sensors are triggered, we will call the piano() function to play a certain note. As declared in the first portion of the code, the moisture sensors would need to reach a reading of greater than 700 to be considered as triggered. For the photocells, they would need to reach reading of lower than 150 to be considered as triggered. This would mean that the moisture sensor would need to be in direct contact with water and the photocell would have to be blocked from almost all light to be triggered.




Materials

Refer to "The code" under code and references of this tutorial.


Step 27

Instructions

Copy and paste the code from “The code” into the Arduino IDE.




Materials

Refer to "The code" under code and references of this tutorial.


Step 28

Instructions

Make sure you have selected the correct port to upload to.




Materials


Step 29

Instructions

Use Ctrl+U to upload and wait for the bottom left corner to show “Done uploading”. This means the code has successfully been uploaded into the freaduino.




Materials


Step 30

Instructions

Now, moving back to the piano, press on the right and leftmost piano keys to trigger the crash sensors. The leftmost key should paly the note C4 when pressed and the rightmost should play C5.




Materials


Step 31

Instructions

Bring your fingers close to each of the photocells one by one. the notes G4, A4 and B4 should sound when your finger almost blocks enough light over each of the photocells.




Materials


Step 32

Instructions

Get a metallic object (a coin, a wire, or anything that conducts electricity) and press it on a moisture sensor such that both ends of the sensor are in contact with the metallic object. A note should sound.




Materials


Step 33

Instructions

Repeat step 24 for all 3 moisture sensors, they should play notes D4, E4, F4 respectively.




Materials


Step 34

Instructions

If any of the steps 22, 23 or 25 does not work. Check the connections of your arduino and the sensor installations.




Materials


Step 35

Instructions

Fit the right piece onto the right side of the piano.




Materials


Step 36

Instructions

Fit the bottom piece onto the bottom of the piano.




Materials

1x Bottom piece


Step 37

Instructions

Fit the left piece onto the left side of the piano.




Materials

1x Left piece


Step 38

Instructions

Tuck the wires and the Freaduino in and fit the front piece to the front side of the piano.




Materials

1x Front piece


Step 39

Instructions

Use the double-sided foam tape to stick the moisture sensors and the photocells onto their respective keys.




Materials

Abit of foam tape


Step 40

Instructions

Pour a small (as small as possible) later of water on the plastic tray and fit the plastic tray onto the big rectangular hole. Be careful not to spill any of the water into the electronics below!




Materials

1x plastic tray and abit of water


Step 41

Instructions

And there you have it, your very own self-made piano!




Materials


Code and References

Completed this tutorial?

Spread the word! Let's get this trending on social media with #letsgethacking #Thepiano