Simple Touch Sensors With The Arduino CapSense Library

Ever thought of using touch sensors on your projects but didn’t because it would be too much work? [Paul Stoffregen] proves that it can be pretty easy if you use the CapSense library for Arduino. Here he’s created three touch sensors, connecting them to the Teensy microcontroller with two resistors each. The larger resistor (looks like 4.7 megaohms here) sends a signal through the copper pad which is read by the secondary pin. Here that pin is protected from electrostatic discharge with the 1k resistors. The microcontroller takes a reading by measuring how long it takes the voltage to change on the input pin.

Since the CapSense library takes care of the timing involved in these readings, all you have to do is decide how your program will react to the numbers that are coming in. In the video after the break [Paul] is echoing the timing figures back through the serial monitor to get an idea of what the data looks like. He experiments with touching the copper directly, and touching it through a piece of clear tape.

We’ve seen the CapSense library at work before in this interactive exhibit piece.


10 thoughts on “Simple Touch Sensors With The Arduino CapSense Library

    1. Duh, the Arduino is just an AVR with a bunch of premade libraries. So everything you can do on the Arduino you can do on an AVR, the AVR can do it faster, but requires more time on the coding.

  1. Very nice, I saw this in the teensy example sketches, but this is a very nice implementation. I remember seeing what was basically a 4 wire touchpad made with either copper clad or aluminium foil, anyone know where that project it? I believe it was featured on HaD…

      1. My hardware is slightly different than the example and mine sits at about 2 or 3 and goes up to 14 or 15 with direct touch and about 9 with a piece of tape over it. Found I have plenty of difference for state change detection.

        Beware, ESD protection matters! I killed the first pin I was testing with even sitting on my ESD mat.

  2. A very nice project, but it would be more useful if you didn’t have to directly touch the strip. In most applicable cases there will be at least a millimeter of glass/plastic between the metal strip and the finger.

    1. Hi, Paul here… the guy who made this little video.

      Proximity effect does work. Obviously you don’t get a really strong change like direct touch or touch through a thin piece of tape.

      I had actually planned another 10-15 seconds to demo proximity effect. It was in my script when I recorded the voice over. But when I filmed the demos, doing 2 takes of each (and fumbling with the screen recording program, camera, lighting, etc), somehow I missed that both times. I had written the entire script, but this seemed like such a simple little project that I didn’t make a written shot list for the actual filming (and screncast).

      The truth is I’m still not very experienced with shooting and editing. When I edited, I realized I had missed that shot. I didn’t use that audio and took it out of the project… rather than setting the whole thing up again.

      I had also _really_ wanted to do animated graphics overlay, instead of those static arrows and circles… especially some sort of animated graphic depicting the current flow and gradual voltage change. But animated graphics in the editing is far beyond my skills. Hopefully someday….

      I’m still learning my way around FCPX and shooting better video. This was my first attempt at a number of FCPX features, like doing a picture-on-picture overlay to show the serial monitor while touching the sensors. I’m slowly getting better. Next time I’ll definitely make a written shot list, so I don’t forget something and have to edit it out.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.