Conductive Ink – Capacitive Sensing Test

Earlier this week I got a conductive ink pen for a competition that I am currently entered in. I had a bit of a muck around with what I could do with it and the first test that I tried was a capacitive sensing control. The control is a simple slider that drive an LED’s brightness. Capacitive Sensing is a technology that uses the capacitance of the body to alter the charging time on an input pin. The larger a contact surface is the faster the charge time will become; Knowing this we can map the surface charge time to a scale and thus the LED brightness.

Capacitive sensing circuit using conductive Ink surface with 1 Megaohm resistor and a 100pf capacitor.

The code below was based on the CapSense tutorial from the Arduino Playground with some additions. I’ve added in 3 sample smoothing and some low end noise reduction. The LED is then mapped to the values coming directly out of the CapacitiveSensor library included in the tutorial.

#include <CapacitiveSensor.h>
CapacitiveSensor cs_3_4 = CapacitiveSensor(3,4);
int led = 9;
long total;
long total_01;
long total_02;
long holdValue;
 
void setup()
{
    // turn off autocalibrate on channel 1 - just as an example
    cs_3_4.set_CS_AutocaL_Millis(0xFFFFFFFF);
 
    Serial.begin(9600);
    pinMode(led, OUTPUT);
}
 
void loop()
{
    long start = millis();
 
    //Buffer Samples
    total_02 = total_01;
    total_01 = total;
    total = cs_3_4.capacitiveSensor(30);
 
    // Average (Smooth values over 3 Samples)
    total = (total + total_01 + total_02) / 3;
 
    // Remove Bottom end noise
    total -= 300;
 
    if(total < 0)
    total = 0;
    else if(total > 11000)
    total = 11000;
 
    //Update LED Brightness
    analogWrite(led, total/43);
 
    // check on performance in milliseconds & Print Total (Debug)
    Serial.print(millis() - start);
    Serial.print("\t");
    Serial.println(total/43);
 
    // arbitrary delay to limit data to serial port
    delay(10);
}

The Conductive Ink Pen worked quite well and was easy to apply, I didn’t need a lot to get a good surface down on the paper to act as a contact. You can see in the video that I made the conductive surface in the shape of a triangle, this provides the variation in charge time. As the finger is in constant contact with the paper, you need to vary the amount of contact surface to drive the change.

I have a couple more sensor ideas that I need to try out in the next few weeks and I’ll keep you posted. If you want to try some out yourself head over to Newark and pick yourself up some, there are some pretty freakin’ cool circuits you can make.