Project: The Two-Way Piano!
Hannah Walsh and Nana-Konadu Attakora
- What is our project and why did we choose it?
Our project is what we call a two-way piano. Similar to many mini-games in well-known video games like Mario Party, one person plays a tune using buttons and buzzers. That tune is turned into a sequence of characters that are sent over Bluetooth to the other piano. The other person has to play the tune on the other piano and if the two tunes match, a light will turn green to indicate that the second person was able to mimic the melody correctly. We chose this project because we both loved music, games, and coding, so it seemed like the right thing to do! It was a lot of fun to make.
- Explain what you had ready on the first demo day and how you improved that for the final demo.
On the first demo day, we only had the buttons and the Bluetooth communication working. The game was essentially working, as in a person could press buttons in order and the other person could mimic those button presses and if they were identical, a green light would light up to indicate that. But at this time, there were only three buttons, no sound, and if you wanted to replay the game, you had to recompile the code all over again. After that demo day, we added another button (piano key) onto each piano and we added all the buzzers and tuned them to different frequencies. We also implemented a replay button, which allowed the players to reset the game to start conditions so we didn’t have to recompile the code every time.
- Separate each subsystem of the project and explain in detail how you implemented it. If it is hardware explain the wiring and how components work together. If it is code explain how the logic works.
The project can be separated into three parts – the sound, the Bluetooth and the coding. For the sound, we set up a variety of buzzers and hooked them up to pins and put them on output mode. Whenever the button corresponding to a buzzer was pressed, we would sound the buzzer using Arduino’s tone library, which allowed us to choose the frequency. We choose different frequencies for each buzzer on a single Arduino. For the Bluetooth, we set up the Bluetooth modules on each Arduino such that one Arduino was the master and the other was the slave. The master would send singular chars to the slave as buttons were pressed. Once a button representing the end of the sequence is pressed, a ‘d’ char is sent to the slave representing the end of the sequence. The slave then stores the input from the master as a string, and then compares it to whatever pattern it produces locally. The code is the most complicated part of the project. In the code, we handle a lot of things. Firstly, we handle debouncing the buttons, by having “old values” for each of the buttons. This ensures that when you press the green button for example, you don’t get a string of 100 G’s. We also handle what happens when a button is pressed. If a certain button value is on high, three things will happen. That button’s character is sent over Bluetooth to the slave (if this is on the master Arduino). The button’s character is also recorded for either comparison (in the slave’s case) or for testing purposes. Finally, the button’s buzzer will sound. Each button either records a note (which we represent as a char) or it submits the char sequence (either over Bluetooth for the master or compares it to the master’s for the slave). One button on the master resets everything. This is how the parts work!
- How this project could be turned into a real product and sold.
We would definitely have to make the sound better, and we would have to add more keys. We would also have to get some kind of piano-like case around the Arduinos to make it look like a small toy. It could definitely be some sort of fun child’s toy!
- Improvements to the project.
We could have used Matlab for the sound instead of buzzers, which would have made the sound so much nicer. We also tried to use flex sensors for the “piano keys” but it didn’t work out. We also could have added more piano keys than just four, but we weren’t super familiar with how analog pins worked.
Thanks for reading!