When linking to these pages, please use the URL:
www.iki.fi/sol/ - it's permanent.
Since last time, the Pi has gained a header (with the "Connect These And The Pi Fries" pins blocked with blu-tack).
And the piano itself has lost the blob board, and gained a bunch of wires (with rather shoddy solder job, but I hope it holds until I get everything inside the box). The image above also shows just how tiny the keys are compared to "normal" piano keys.
I connected the wires to the Pi and started working on a GPIO analysis tool.
The tool more or less works, but the signals I got out of the piano were strange. I found a few reasons for this.
First, since I had not labeled the wires, I had no idea what order they were in. Second, the Pi's pull up/pull down resistors were configured in more or less random order, so signals got pulled every way. Setting them all to pull up resulted in weird results; a couple pins did not want to be 0 by default. After suspecting some kernel daemon messing things up etc, I found a note on some forum thread noting that the pins 2 and 3 have fixed pull-down resistors. So I set everything to pull-down for now. If that doesn't work out, I'll just have to use some other GPIO pins.
Third, the piano keys themselves pretty much require the box to be screwed shut, or otherwise the long circuit board just flexes which is not a good thing. So I need some way to get the wires out of the box while having it closed. Which means making a hole in the box.
Of course, when I started labeling the wires, I found that at least one of the wires was loose. (See "shoddy solder job", above).
At that point I figured it's time to take a break, and put the project on a shelf for a couple weeks.
When I picked the project up again, I tied all the wires together to create a common hard point which is hopefully better for the solder points - the wires should bend from the common point rather than from the solder point. In theory, at least. The negative side of this is that knot is a bit big and may cause problems when I squeeze the box closed.
I also opted to put the pi inside the case. My first idea was to use screws to connect the board to the bottom and then dremel the excess screws off the bottom, but turns out that the plastic is fraction of a millimeter thick and thus screws wouldn't hold. So I made four holes and tied the pi in there.
I also dremeled a rough hole to the back of the case to get the USB cables out.
And this time I wanted to make sure I know which wire is which, so I labeled them all.
So I wired the cables so that I used the first 11 GPIO slots, 0-10, and then carefully closed the box. Experimenting with the signals I found that pins 2 and 3 were linked; either there's something going on with the pi, or I managed to short circuit something when soldering. So I opened the box again to move the wires.. and so many wires got loose that I got frustrated and moved the box on a shelf again for a few days.
After I picked it up again and moved the cables pins 2 and 3 to 11 and 12, got the box closed again, and got to testing again.
To reiterate: I was using pins 0,1,4,5,6,7,8,9,10,11 and 12. When I tried different keys with different pins in read and write position, I found that I got reactions from pins 15 and 25. What the? Either the pinout.xyz is not accurate for the pi zero, or there's something going on I have no idea about, or there's some really, really weird soldering problems going on.
I rewrote my GPIO analysis program, ditching the interactive state display and made it to scan all GPIO configurations to see if there's any life when I press the piano keys. What I expected to find, if everything worked right, is that when a key is pressed, multiple GPIO pins go to 0. This didn't happen, though. Additionally, the only pins that had any kind of effect were 0,1,4,5,8,10,15 and 25, so only 8 wires did anything out of 11. Possible reasons for this include bad connections to the pi (easy enough when I had to squeeze the box closed), bad soldering, or even broken circuit boards. Crap.
On positive note, the signals that I did get seemed logical - one pin being responsible for a bunch of adjacent keys.
As the next step I took the pi outside the box and pulled the wires out of the hole that I had dremeled, planning to plug them in outside the box. That should at least say whether it was the case of bad connections to the pi. The wires are tad bit short though so connecting them to the pi was so frustrating I put the project on a shelf again.
And that's where I'm at, primarily waiting for inspiration to tinker with it again.
I'm still waiting for the usb audio device to come in the mail. When that arrives I can play a bit more in the software side. At the moment I'm not all that certain if that toy piano will work out at all. One idea would be to plug an USB midi keyboard to the pi and using PortMidi to get the keys.. in which case I'd be using the pi just like a regular computer though. We'll see.
So happy 2017, let's hope it's better than 2016 was. Bound to be, for some people at least.
Anyway, here's the demo:
I also wrote breakdown of last year's demo even though nobody asked for it.