In case you missed the piano lessons you're going to have a hard time. The box will play a tune and your job is to repeat it and learn to play. However you won't use a regular piano keyboard but a 5 button array of super tactile cherry switches. This was actually the seed to this level, I wanted to give the player the satisfaction of pushing these buttons. But I'll start in the other end. How do we get the tunes?
I wanted to be able to play fairly hi-fi sounding piano tunes and so the Arduino was not sufficient, at least the not existing stuff I could find. I came up with two options.
1. I want to add an mp3 player to the box so that you can have a theme-song to every level. I could have created an mp3 track for each note and play a corresponding track each time a note is pressed.
2. Acquire a toy keyboard and remove the keyboard and take out the tune-IC and give input from an Arduino instead. This is the option I went for.
So off I wen't to the toy store for the first time in many years, I found this little keyboard for a good price and immediately took it apart.
Turns out all buttons on the keyboard (25 different notes) are played by connecting the following wires.
The fire wires on the left each have a unique digital signal pushed out to them and the five on the right are listening for a signal signal. The combination of what signal is sent and what pin receives it determines what note to play. I also noticed that the IC on the synth circles around the pins and only plays one signal stream at a time (a kind of multiplexing). Below you can see one of these signals on the scope.
This was not what I expected and made matters a bit more complicated than I'd hoped for. I though that I could simply control these by pulling the pins low or high but instead I had to route the signal using the Arduino. I bought two of these DG418DJ analog signal switches.
I wanted a simple song and found "Marry had a little lamb". This was great since it could be played using only 5 keys. Below is what the player will have to imitate in four segments, one per row.
I 3D printed a holder for five cherry switches and put them in place. I had a bunch of extra buttons and they all looked the same. Maybe I'll write the notes on them but it's a bit too much of a giveaway I feel.
The small speaker on the keyboard was not loud enough, and I needed a larger speaker setup for the mp3 soundtrack anyway. And now it came quite handy to have the analog switches with free channels because when this level is active the box will swap the speaker input from mp3-player to the keyboard circuit and then back again when it is over. As usual the dumpster came to rescue with a basic but perfectly working computer speaker system. I removed the power amplifier and the SMPS from the subwoofer box and skipped the woofer speaker entirely. All this could later be mounted inside the box.
After soldering on a ribbon cable and connecting the cherry buttons, the keyboard circuit and the analog switch ICs I could try the whole setup. It worked!
Now everything could be soldered onto a board and mounted on the panel. I added a external volume control that will control the volume of both the music and the keyboard. The speaker on the board is the one that came with the keyboard and it's there just for testing. It won't be active when it's all done.