I've grabbed some very cheap TTP223-based touch pad PCBs so this is showing how they can be used as a replacement button in a simple Arduino MIDI controller.
Warning! I strongly recommend using old or second hand equipment for your experiments. I am not responsible for any damage to expensive instruments!
These are the key Arduino tutorials for the main concepts used in this project:
If you are new to Arduino, see the Getting Started pages.
Parts list
- Arduino Uno or Nano
- TTP223 "touch button module"
- MIDI interface
- Breadboard and jumper wires
The Circuit
The really neat thing about these TTP223 based modules is that although they are touch pads, all the touch "magic" is handled by the onboard device, so when it comes to linking them up to a microcontroller, they can be treated as if they are a simple button, albeit with a VCC and GND connection. In the above I have four connected to D2-D5.
There are some configuration jumpers which can set the configuration:
- Active HIGH or active LOW (active HIGH is the no-link default)
- Momentary or toggle (momentary is the no-link default)
Here are some other resources for finding out a bit more about these boards:
Each of these modules also has the opportunity to adjust the sensitivity. In the datasheet and circuit diagram for the modules, this is labelled Cs and is a capacitor between the value of 0 and 50pF between the input touch pad and GND. Having no capacitor leaves the sensor at its most sensitive.
On these modules this is an unpopulated SMT capacitor pad. In the photo below, the unpopulated pad is top right; and the two solder jumpers are labelled A and B.
Typically for these modules, A is the active HIGH/LOW and B is the momentary/toggle configuration.
I'm connecting TX (D1) up to the output of a Ready-Made MIDI Module.
The Code
The code is essentially code I've used many times before. As already mentioned no special handling is required - they are treated as if they were buttons.
The main code is thus as follows:
loop():
FOREACH button:
If LOW->HIGH detected THEN:
Send corresponding MIDI NoteOn message
IF HIGH->LOW detected THEN:
Send corresponding MIDI NoteOff message
There is a list at the top of the file of button pins and corresponding MIDI notes to be played. The keyboard is fully polyphonic.
There is one downside though. If the button is held for more than around 8 seconds then the board will recalibrate itself causing a retriggering of the note. That just seems to be a built-in limitation of the 6-pin version of the TTP223 device that is used on these cheap modules.
Find it on GitHub here.
Closing Thoughts
These modules are pretty easy to use and very cheap to buy. They typically come on a panel to be broken out and have pins soldered on so its possible to get a couple of octaves worth for really very little!
In one demo I saw online someone had just hooked up the output to an LED (and resistor) highlighting that they function pretty well even with no microcontroller.
It would be interesting to see how they could be matrixed up, but I suspect if getting into large numbers, then using a MPR121 breakout board might still be the better option.
One thing I didn't mention though - they each have a built-in LED, so the underside also lights up when touched. This creates a really interesting effect 🙂
Kevin
No comments:
Post a Comment