Capacitive sensing with Arduino

capsense setup

The setup for capacitive sensing is really simple.

I stumbled upon a nice instructable which allowed your Arduino to be used as a touché-style sensitive device. This means essentially, that Arduino / Processing can turn any electricity-conducting surface in to a touch-sensitive interaction playground. The problem was that the messages were sent using a weird byte-encoding stuff that I really couldn’t read.  Then a student found out this library. Arduino Libraries are added to Arduino in os x by right-clicking (or ctrl+click) Arduino application in Finder, choosing Show Package Contents, then Navigating to Contents > Resources > Java > libraries CapSense, Capacitive Sensing Library allows you to measure capacitance of he human body by measuring a delay of triggering a pin between its two sensors, the other having a big value resistor in it. Hooking up three resistors from the example on the CapSense was very simple and I was playing and manipulating music with three custom sensors in no time. Be sure to use latest version of Arduino and the Library, the library name has changed from CapSense to CapacitanceSensor, and I had some problems first using the code – the library was not recognized and I got an error: capSense does not name a type.

Sensors for capacitive sensing

Creating your own sensors is fun!

The biggest resistors we have at the lab are 1 MOhm, but they seem to work. I tried out different materials and – surprise surprise – got different readings from Arduino. Playing around with the values it is possible to create a touchless theremin-like system even through wood or plastic, or to use the metal objects themselves.  The script could be improved with some kind of averaging algorithm, but it works pretty well. Once in a while I had to reset arduino to jump back to original values. Here is a Quartz Composer file that picks up data from Arduino, displays the values and sends them out as midi control channel messages (to Ableton Live for example). This one is now configured for the sensors you see, and touchless operation. QC displays the midi values in the middle (bouncing them up and down) and original values (coming from Arduino) in the bottom.

setup for capacitive sensing 2

One common pin and three pins for the resistors.

Make your own theremin!

Arduino CapSense Theremin from tomi knuutila on Vimeo.