Interactive Teaching Piano
In this instructable, I will be showing you how to make an Interactive Teaching Piano that teaches you how to play a song or melody. This will include the Circuit Shematic, Circuit and Code to help you build this project. This project combines the Arduino and Digital Circuits unit.
Supplies
- Arduino
- 555 Timer IC
- 6 x Push Buttons
- Buzzer
- Capacitor: 100nf and 10uf
- Resistors: 6 x 1K and 1 x 4.7k
- Breadboard
- Jumper Wires
All of these supplies are essential for this project to be successful and for everything to work smoothly
Ciruit and Schematic
This is what the circuit should look like and be wired the same. After the wiring all your components, make to connect to the power supply on your arduino by taking a wire from the negative (-) rail on your breadboard and connect it to GND pin on the arduino. For the power, connect a wire from the positive (+) rail on your breadboard and connect it to the 5V pin on the arduino. After connecting the power and ground, Press all the button you connected to make sure that there is sound coming out.
I also highly sugguest looking at this video to follow the wiring step by step
if there is no sound, try checking your connections and check if everything is in its right place.
If there is Piano like sound coming out of the buzzer, Congratulations, you are done the first step :).
The Code
The purpose of the code is to create an interactive learning piano. First, the Arduino plays a melody so the user can hear it. Then, the user must replay the melody using the buttons. The program checks each note one at a time and gives feedback. When the user plays a correct note, it goes to the next note and etc until the entire melody is played correctly which then a congratulation message gets displayed and we will be doing that showing you how to a play a simple and well known melody.
For your buzzer to play the melody, you will need a pitches file which I have attached at the buttom. Just press CTRL + SHIFT + N to make a new file, name it Pitches.h and copy paste or download the code of the frequencys for the notes.
In the beginning of the code, variables are declared for each button input and each Button represents a musical note (C4, G3, A3, B3). Each of the button that represent is the notes are connected to the arduino. In the code, you will see which button is connected to what pin, example: Int C4 = 9; which just mean that the C4 button is connected to Pin 9 on the breadboard. Also the buzzer is connected to pin 8 as it is being declared as noTone(8);. The Score variable keeps track of which note the user is currently on. A finished boolean variable is used to make sure the congratulation message only prints once when the user is done playing the song correctly. The For loop is used to play the melody one time at the start of the program.
After the melody plays, the program waits for user input. Inside the loop function, the program checks which note the user is supposed to play using the score variable. Each If or else statements checks the current score and which button is pressed. If the correct button is pressed, the program prints the next note the user should play and the score increases by one. This makes sure that the notes are given one at a time and are being played in corrent order.
Finished
After making sure that the circuit and code works, Congratulations, you have now built a Interactive Teaching Piano. Enjoy!