Testing CapSense

Although Arduino has many fun programs in its library, I was in search of something a little more touchy-feely.  To be more specific, something that is touch sensitive.  I found out that someone had written a CapSense program for Arduino here.  This program gives the user the ability to create an object that when touched, will trigger an event.  Think of those lamps that when you touch the base, they act as a switch adjusting the brightness of the lamp or turning it on/off.  Sounds useful, right?  So, I set about uploading the program and doing a test.

The Lilypad Arduino has what is called pins around the outside circle.  That is a very electronic term, but basically they are the little holes you see on the edges that allow you to attach parts.  I’m just going to call them petals because the whole thing looks like a flower anyway.  Leah has a great diagram here to show what these petals are called.  Notice that some of them are marked “D” and some of them are marked “A” — this means Digital vs. Analog.  More on that when it is appropriate.

The way this capacitive sensing works is that it measures the electrical capacitance of skin as it touches or nears a pin.  In fact, it is similar to what a lie detector test is doing when you are hooked up — except the detector is looking more at changes from emotional stimuli rather than touch vs. no touch.  For my project, all I need is the second.  It takes two pins for each touch sensitive area, so I first had to connect a 1 M resistor between two of the petals that are used in the program.  I didn’t want to solder or use conductive thread since this was just an experiment, so I utilized a breadboard (not to be mistaken for my cutting board).  A breadboard allows you to connect various parts of a circuit and just use alligator clips to connect to your project for testing.  Once I had the resistor in place, then I needed something to act as the conductive metal to “touch” in order to trigger change in the program.  Some people make simple piano keys using some copper tape, but I decided to use conductive yarn.

So, here you have the setup, the alligator clips lead to the breadboard with the resistor and then there is the conductive yarn ready to be touched.  Remember the power is actually coming from the USB connector attached to my PC.  There’s one other thing that I want to point out here, I’m also using a circular yellow piece of craft foam as a coaster underneath the Lilypad.  This coaster allows you to clip things on without the whole thing sliding around — quite handy.  So, now it’s time to do the test.  First I have to turn on the Arduino monitor to allow me to see live data flowing, which  in this case will be numeric values for the petals in operation.  This particular CapSense sample program uses three possible touch sensitive areas, but I’ve only hooked up one for the test.  So, that means there will be three columns of values with only one column actually activated.  Let’s see what happens when I touch the yarn…

As you can see in the first column, there is a string of relatively low numbers which then shoot up at line 3907.  That is where I touched the yarn — success!  Notice they drop down again a few lines later once I’ve released the yarn.  This is exactly what I was hoping for.  So, in my case, I want the project to sense when I’ve touched yarn, in order to trigger a sound.  However, I won’t be able to get to that until I’ve done another round of testing with CapSense with more inputs.  I would really like to figure out how to have six to eight touchable areas instead of just three.  That will probably take some minor code hacking, but I’m not worried as it’s already been a great day.  Now I have to plan a visit to Radio Shack in order to get more 1M resistors.  I used to work at Radio Shack a very long time ago, and it’s still funny that I remember codes for some of the part items.  So geeky.  Sayonara!


One thought on “Testing CapSense

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s