Arduino Capacitive Switches

In this experiment I am going to use my first outside library to add Capacitive Sensing to the Arduino as demonstrated on You Tube.   This is the same technique used by most modern touch screen such as the iPad and iPhone and this feature is brought to the Arduino via the CapSense library written by Paul Badger.

Installing the CapSense library.

To install the library it needs to be downloaded from the playground and placed into a folder called libraries inside your Ardiuno Sketchbook (the place you store all your Ardiuno projects).

Ardiuno library location for the CapSense Capacitive Switching Library

Restart the Arduino IDE, open the project you are working on and then use sketch > import library to import the CapSense library into your sketch.  At the most simple level you need to create a new CapSense object where pin 7 represents the source and pin 8 the signal lead.

and then inside the loop function you can call the CapSense object and test the current value.  The value returned is in an arbitrary unit which you can test against and of course respond to.

For more information you should refer to the documentation written by Paul Badger.

Creating the Switches

The switches can be created using a number of different techniques including a paper clip and a piece of wire.

The circuit should look something like:

The recommended resistor value is anything from 50kΩ to 50mΩ with 10mΩ given as a starting point.  Personally, I found that too low and need to pop a couple in series to give 20mΩ.

The following video shows the switches under operation without the stabilising capacitors suggested which I need to order.

/**** UPDATE ****/

So after a slight delay due to distractions I have added a stabilising capacitor to a single touch switch.  I’ve also changed the design of the switch as shown below.  In version 2 I have been able to glue some foil between the wood and paper.

In actual fact I found that the sensitivity of the switch varies greatly depending on whats around it. Three switches was less sensitive than a single one but once I had mounted the camera on the edge of the board the switch became so super sensitive it was more of a proximity sensor than touch sensitive switch!

Anyway, experiment over – next!

Here is the code I used for those that asked.  You will need to remove the .txt file extension. (12/01/2013)

Last Updated:
Posted in Arduino

Comments 6

  • mattias bouchier

    do you have a example of the code that you used to turn on de leds when you touch the paperclips?

  • adrian

    I belive that the scheme from section “The circuit should look something like:” is wrong. All 3 sense pins will see the same voltage. The 3 resistor are conected in parallel to the same point.

  • jasper

    I agree with Adrian the 190pF caps should not be connected together. Each should be connected to its corresonding receive pin.

    • CDB

      Quite possibly, I’m not an electrics expert and am only finding my way with these experiments or could have easily made a mistake drawing up the circuit. I’ll try and find a moment to double check.

  • grace

    Hi , I am currently doing the same project.. Do you know how can i download the arbitrary unit obtained from the capacitor sensor and make it into graph ?

Write a Reply or Comment

We will not publish your email.*