This week challenge is to create and program a board that measures something. I was intrigued by the step response sensors, as they are really general purpose and allow to measure a lot of different things.
For my final project I will also need to create a microphone and other sensors, but the capacitative touch is one of them and this can be done using the step-response mechanism. I was also very impressed by the 4$ touchpad and the capacitative multitouch projects, but wanted to do something different of course.
After thinking about possible uses for capacitative sensors, I decided to go for a tiny MIDI keyboard. Actually I would not send real MIDI using the microcontroller but I can implement all the midi protocol on the PC side, just sending the notes using the serial link.
As shown in the 4$ touchpad project, the ATTiny44 has an analog multiplexer hooked to 8 pins, this is more than enough for a small one-scale keyboard, and I decided to use all of them to provide 8 notes.
The board uses 1M resistors as indicated by Neil design, and is quite large to make space for the pads. I also had to remove the VCC net from the ISP programmer, this makes the layout easier and the pin is not used anyway in my USBTinyISP, but I left the GND net. I also placed the FTDI header in the middle of the board. Even if this looks bizarre, it will work fine if I manage to solder the pins in a straight position, otherwise I could also solder cables to the four pins used and hook them to the FTDI cable.
DISCLAIMER: As described later in the page, this design is flawed, don't used it or you will have two pads not working.
Milling and stuffing the board is getting easier having done it few times. I managed to solder the FTDI header vertically without much difficulty. Of course it's less resistant than the one laying on the PCB.
As soon as I started programming the board, I realized I made a mistake in the board design. Sharing two ATTiny44 pins, used for serial communication, also for sensing two of the pads. Actually I could have easily used the other two PB0 and PB1 free pins for the serial communication and leave the two pins of PORTA for sensing. This results in two pads not working.
One solution for this could be to cut the traces going to the FTDI header and create alternative routes using wire. I plan to make an updated version of the board, maybe with a different MCU and leds. In fact I decided not to redo the same design as it conceptually works and I would like to improve it in different ways apart from fixing the two dead pads.
Back to the programming, for the microcontroller code I used a variation of the 4$ touchpad code, sending pad number and touch on/off events on the serial link.
For making something useful with these inputs, I wrote a Python script which reads these events from the serial connection and repurposes them as OSC (Open Sound Control) messages to an OSC server, using the PyOSC module. This is now the standard for electronic music controllers, and can talk to a wealth of local or remote software.
For interpreting OSC messages I used a Mac application called OSCulator. This is basically a server mapping and routing OSC messages to different targets. In my case the mapping is converting OSC messages sent by the Python script to MIDI packets delivered to the Garageband application by Apple.
This way my board can play notes on a virtual piano instrument as shown in the video below
This version replaces the old one moving the TX and RX pins to PB0 and PB1, leaving the analog inputs free for the two buttons not working in the original version.