How to build your own wearable drumkit
Note: this is a project that I presented at the
2015 Toronto MakerFest event.
So everybody loves wearables and people are making their own. Big companies like Apple are making their own wearable technology and there are companies only for wearables. So I thought would it not be cool if I were to build my own. But I had to mix my wearable with something I like such as music. Therefore I fused the two and out came up with "the wearable drum kit." Another reason I had to make it a wearable is because everybody else has a wearable... even puppies do!
My design is composed of an Arduino hooked up to a capacitive touch sensor and also connected to a PC. You hook it up to anything that is conductive and it will start playing music through the PC. How this works is when you move your hand close to an electrically conductive material, its capacitance changes. The capacitive touch sensor is able to detect this tiny change in capacitance of the object and it will automatically send a signal to the Arduino through the I2C communication. The arduino emulates a keyboard and sends a key press command to the PC when this event is detected. If the PC has a music program setup to play notes when a key press occurs, you can get the PC to play music every time your hand gets close to the touch sensor. Simple!
Here is me proudly wearing my final design as a necklace. The touch pads are the tiny aluminum squares you see at the end of each long LEGO piece.
Another close up showing the Arduino Leonardo, CAP1188 breakout board and contacts all attached to one LEGO frame. The only outside connection is a USB cable to the PC.
The Materials required are:
1. Arduino Models: Leonardo (see below for why you need Leonardo)
2. CAP1188 (capacitive touch sensor) found
here.
3. a few connection wires
4. aluminum tape or foil
5. scotch tape
6. A few lego pieces as a base or a 3d printed non conductive enclosure
The maker process
As most makers do I had to look for inspirations for this project. So I browsed the web patiently. What you don't expect me to invent everything do you. I actually came across something called the beet-box get it. Beet box. You will see why it's a word play. Well that gave me the idea of touch capacitive sensor. So at that time all I wanted to build was a interactive drum kit but then I saw Drumpants I knew at that moment I had to make a wearable drum kit.
I have the link below for
Drumpants: https://www.youtube.com/watch?v=6VS2jWqFKM0
The steps:
STEP 1: Prototype
IN this step you shall be trying to make only one sensor work just to make sure that everything is working. So my goal is to build a quick and dirty test. I hooked up one wire on the breadboard to pin C1 of CAP1188. Then I connected CAP1188 to a Arduino Leonardo using I2C. For detailed instructions on wiring click
here. In the wiring instructions just follow the first segment using I2C. Some problems you may encounter are a double tap but you just have to add a simple debounce to the code or just make the wait a bit longer. See below for sample code on how to deal with issues. Hopefully the comments will help.
One precaution you have to take is making sure the wire to the capacitive inputs should not be too long because the sensor will sense your hand from a long distance.
STEP 2 : Layout of the shirt
This might be one of the hardest parts of this entire process. You have to decide how to place your touch capacitive sensors. Lucky for you, I went through almost every mistake so it might be easier for you. Before we move on I'd like to show you the failures I've been through.
First, I built my dream wearable. The touch pads were conveniently located on a shirt. Copper tape was used to connect it to the side of the shirt where it would be connected to the Arduino through the CAP1188. But There were two problems. The first being that it would false trigger with the slightest body movement because the sensor would rub against my body. Then because the copper strips were too long, they started to act as if they were sensors and whenever my hand was above these copper strips it would trigger randomly. Here is an illustration of my dream design.
Then I tried to insulate the shirt. I put a copious amount of electrical tape around the shirt. But it still did not work because I did not change anything about the copper tape. So it continued to trigger randomly.
My next attempt involved putting the whole design on a card board piece. I encountered a new problem. In this scenario the paper was still changing the capacitance of each touch pad. So it continue to trigger randomly :-(
This motivated me to come up with a design that was totally non conductive. LEGO to the rescue! This worked because Lego pieces are plastic and thick. So they are not conductive. Also, the design made everything compact. So all the wires were as short as possible. The wires also did not move as much because of the design was rigid. You can see this design at the top of this post.
STEP 3: Hook it up to a music synthesizer after programming
I started with the sample code that came with Adafruit's CAP1188 board. You have to use a Leonardo here because it readily emulates keyboards. The UNO does not support this cool feature. The setup of Arduino Leonardo programming to use the CAP1188 is given
here. You will notice that you have to download a special library and add it to the programming environment. Then you will have access to the sample code. I was being creatively lazy and definitely made use of this sample code.
Now I had to code the Arduino to emulate keyboard commands every time a touch pad was touched. I used the Keyboard function that comes with Leonardo to send keyboard commands when a capacitive touch event occurred.
In the example code below you will see that I sent key presses '2', 'k', 's' and '6' when one of the four touch pads are contacted.
/***************************************************
This is a library for the CAP1188 I2C/SPI 8-chan Capacitive Sensor
Designed specifically to work with the CAP1188 sensor from Adafruit
----> https://www.adafruit.com/products/1602
These sensors use I2C/SPI to communicate, 2+ pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_CAP1188.h>
// Reset Pin is used for I2C or SPI
#define CAP1188_RESET 9
// CS pin is used for software or hardware SPI
#define CAP1188_CS 10
// These are defined for software SPI, for hardware SPI, check your
// board's SPI pins in the Arduino documentation
#define CAP1188_MOSI 11
#define CAP1188_MISO 12
#define CAP1188_CLK 13
// For I2C, connect SDA to your Arduino's SDA pin, SCL to SCL pin
// On UNO/Duemilanove/etc, SDA == Analog 4, SCL == Analog 5
// On Leonardo/Micro, SDA == Digital 2, SCL == Digital 3
// On Mega/ADK/Due, SDA == Digital 20, SCL == Digital 21
// Use I2C, no reset pin!
Adafruit_CAP1188 cap = Adafruit_CAP1188();
void setup() {
Serial.begin(9600);
// keyboard initiationlization
Keyboard.begin();
Serial.println("CAP1188 test!");
// Initialize the sensor, if using i2c you can pass in the i2c address
// if (!cap.begin(0x28)) {
if (!cap.begin()) {
Serial.println("CAP1188 not found");
while (1);
}
Serial.println("CAP1188 found!");
////from post https://forums.adafruit.com/viewtopic.php?f=8&t=49138&p=247522&hilit=1188#p247522
//
//uint8_t reg = cap.readRegister( 0x1f ) & 0x0f;
//cap.writeRegister( 0x1f, reg | 0xF0 ); //0xF0 is slowest and 0x04 is default
////NOTE: Above code is for sensitivity. Key bounce delay is set at 0x22 register (pg. 49/50 of CAP1188 manual)
//
uint8_t reg = cap.readRegister( 0x22 ) & 0x0f;
cap.writeRegister( 0x22, reg | 0x04 ); // or whatever value you want
}
void loop() {
uint8_t touched = cap.touched();
int touchedPin;
// I put two lines here to fix double press problem
delay (50);
touched = cap.touched();
if (touched == 0) {
// No touch detected
return;
}
// complicated code to figure out which pin was touched
for (uint8_t i=0; i<8; i++) {
if (touched & (1 << i)) {
touchedPin = i+1;
//Serial.println(touchedPin);
}
}
// if touchedPin is 1 then send keyboard command 'a'
// if touchedPin is 2 then send keyboard command 's' etc. etc.
if (touchedPin == 1) {
Keyboard.write('2');
delay(150);
}
else if (touchedPin == 3) {
Keyboard.write('k');
delay(200);
}
else if (touchedPin == 5) {
Keyboard.write('s');
delay(200);
}
else if (touchedPin == 7) {
Keyboard.write('6');
delay(150);
}
else
{
touchedPin = 10;
}
}
STEP 4: Find ways to advance your own wearable drum kit
I have shown how to emulate keyboard commands in my project. It will be amazing if the device can send MIDI commands. This way, you can hook up the device to any MIDI device such as iPad, iPod touch or a smart phone. This will make the whole design whole lot more portable. Let me know if you manage to get MIDI working with Leonardo by commenting below.
STEP 5: Have fun and post back your successes (and failures). I will try to help where I can.