This week, we were tasked to do something with analog input, and a tone-based interface. 🎵
I worked on something which I felt was technically challenging from an Arduino software stance. (I would have liked to make a container for it, if only I had the time. The interface itself is more bare bones!)
I was inspired by the form factor of Launchpad-type interfaces. You can see Shawn Wasabi using one here:
On my last trip to Tinkersphere, I found one of these 4×4 button matrixes. It’s like the cave-man version of Shawn Wasabi’s instrument.
There are 8 pins total. 4 pins correspond to columns, 4 pins correspond to rows.
I wanted to build something where each button would correspond to a note, so you could play different songs. Like a puny, gridded piano!
I relied on several websites for instructions and debugging help. I’ve linked to most of them at the bottom of this post.
In order to set up the matrix grid, I used code which looked like this…
The mapping wasn’t intuitive for me; I used the Serial Monitor and old-fashioned pencil-paper to keep track of which values corresponded with which keys.
Early on, I was able to use “case… break… case… break…” formatting to conditionally turn on and off an LED.
After importing the tone library, I struggled with debugging my Piezo and code for a couple of hours. Incorrect wiring, messy functions, variable salad!
My final working code plays a frequency based on what key was pressed. It also has a “toneOffset” which can controlled by a potentiometer to change the pitch of all keys.
Here are some the resources I referenced when building this:
Piezo + Tone Control