Introduction: 8 Bit Mario Bros Piano
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com). My name is Maria Fontiveros and I decided to make a piano out of 12 different coins from 12 different countries. I wanted this piano to be something fun but useful, therefore I built it as a musical box which can actually open itself.
Step 1: Materials
For this project, the following components or materials are being used:
- Arduino UNO board (you can use other micro-cotrollers but the pins or program might be different).
- Adafruit 12 Key Capacitive Touch Sensor
- 2 Ohm Speaker
- Touch Sensor
- 1 button (you could add more if you want a wider variety of sets of musical notes)
- 9V battery (to power Arduino)
Step 2: Test Your Capacitive Touch Sensor
Once you get the chip showed in the picture above, you should test it to verify it actually works. Simply download the sample code and library through this link and then see that the sensor will know when you are touching one of the pin-outs and which one you are touching. In order to do this, you might have to solder some pins first and then connect Vin and GND to power and ground respectively, as well as IRQ and SDA to A5 and A4 accordingly.
When you get this working, it means you are ready to try to put some music to it. You can use the "tone" library that should be already in your Arduino application and define the frequencies of the musical notes you want to play. You can find the frequencies for all musical notes in this table. Finally, you attach the speaker to one of the digital pins defined in the Arduino sketch and you are ready to listen to some music.
The code for this step is available right below:
Step 3: Control Your Servo With a Touch Sensor
Now, let's try to control the servo by establishing its position while using a touch sensor. The way it works is that each time the loop runs it is going to set the position according to the value the touch sensor is giving. In that way, it is going to maintain the same initial position of 0 degrees until you touch the sensor, which will change it to, in this case, to 90 degrees.
Your circuit should have both the servo and touch sensor connected to power and ground. Then, you would have one more cable left (the signal cable) attached to a digital pin. For this sketch, the servo is attached to pin 9 (RPM) and the sensor is defined as Interrupt 2.
Here you can find to code to try this:
Step 4: Combine and Play
Now that you have all of your components working separately, it is time to put them together. For this project it is very simple: just wire the cables of both of your "tests" to the same Arduino board (you may keep the previous selected pins) and combine the codes. In the picture above you can see the breadboard set up.
After this, you can also add some features to what you already had. For instance, I added a button that would switch between two different sets of musical notes, in order to allow me to play different songs. As the box is Mario Bros themed, I inputed the frequencies of the musical notes for the Mario Bros theme and the typical set from Do-Si, in order to play any other song in that octave. To make this button work such that you can press it once and stay in one set of tones, you have to define another variable which will have an equation to make it work.
All of this you can see in the final code of my project attached next:
Step 5: Result
Now you have a working piano made out of coins! And if you decided to make it as a box then you also have a way to keep some stuff stored or carry the materials for new projects. Hope you liked the idea and enjoyed building this project.
We have a be nice policy.
Please be positive and constructive.