In this tutorial, we are going to make a simple capacitance sensor using a pad of Bare Paint, an Arduino and a resistor. When correctly constructed, this sensor can detect the presence of a person from up to 300 mm and can work behind any non-conductive material (glass, wood, plastic, etc).
By the end of the tutorial you'll have a pad of Paint connected to the Arduino, sending a stream of numbers to your computer's serial port. In later tutorials we'll take a look at what you can do with these numbers. This tutorial is based on the CapSense library and code that can be found here:http://www.arduino.cc/playground/Main/CapSense. All credit for the code goes to Paul Badger for making this so easy to implement!
|
|
Arduino UK: RS Farnell Arduino.cc US: Jameco Sparkfun
Breadboard UK: RS Maplin US: Jameco Sparkfun
Jump Wires UK: Maplin US: Sparkfun
USB Cable UK: RS Farnell US: Jameco Sparkfun
Resistors UK: Maplin US: Sparkfun
The first step is to gather the appropriate materials, listed above
To make a capacitance sensor using Bare Paint, you'll need:
1. A jar of Bare Paint
2. Small selection of resistors, between 100k ohm and 20M ohm (specific size is not important)
3. An Arduino, preferably Uno, Duemillonove or equivalent
4. Solderless breadboard and some jump wires
5. Some general prototyping materials to connect the pad of Paint to the Arduino, like wire, alligator clips etc
6. USB cable to connect the Arduino to you computer
Now that you have your materials together, its time to start building the sensor and the circuit. First you need to paint a pad of Bare Paint onto any non conductive surface. In the video above we've just painted a piece of paper (as seen in the image below). The shape isn't important and the size should be around 100mm x 100mm (4" x 4"). The size of the pad can impact the sensitivity of the sensor, so try a few different sizes if you want and see how this changes the way that the sensor reacts. Leave your sensor pad to dry.
The next step is to build a simple circuit (pictured in image below) containing a resistor between pin 2 (orange wire connecting to the breadboard) and pin 4 (red wire connecting to the breadboard) of the Arduino board. Pin 4 is referred to as the "Sensor Pin" and Pin 2 is referred to as the "Receive Pin". An easy way to create this circuit is via a solder less breadboard.
Once you have your circuit built you can connect it to the pad of Paint. Take a look at our connecting tutorial for cool ways to connect to the Paint, but for now, we're just going to use a paperclip soldered to a wire. Whatever the connection type is, the Paint needs to be connected electrically to pin 2 on the Arduino. In the image below, you can see that the green wire is connected to the same row on the breadboard as the orange wire. For further explanation, includinging a wiring diagram, check out the Arduino playground here.
Great! Now all of the physical work is done and we're off to the code. Make sure that you've downloaded and installed the Arduino programming environment. If you haven't, you can find it here. Next, you'll want to download and install the CapSense library, which can be found here. When you unzip the files make sure to put the folder titled "CapSense" into Documents/Arduino/libraries as shown below.
You will know that you've installed the library correctly when upon restarting Arduino you are able to select it from the Sketch / Import Library… menu, as seen below.
Now that the library is installed, download the Arduino sketch here. Unzip it, open it in the Arduino application and load the code onto your board. For more information about loading software onto the Arduino the Arduino site here.
Now we are ready to test your sensor! Make sure that your computer is plugged into the wall, or the Arduino is connected to ground as this improves the stability of the sensor. To check the output of the sensor, open the Serial monitor in the Arduino programming environment (make sure the monitor is set to 9600 baud as that is what is specified in the code). If it is working correctly, you will see a stream of numbers like in the image below. Moving your hand closer and farther from the pad of Paint should change the outputted number. Try swapping out the resistor and test how it changes the sensitivity. Larger resistors tend to make the sensor more sensitive and as such it will work from farther away.
Hey, it works! As Bibi moves her hand up and down the numbers on the serial port monitor change. It's now time to start experimenting. Try swaping the resistor, the pad of Paint or try covering the sensor with another non conductive material. This type of sensor can work on a lot of different surfaces and materials. In later tutorials we'll look at how we can use this sensor to control lights and sound. We want to see what you do with thie tutorial, so email us at community@bareconductive.com.
If you don't already have it, make sure to download the Arduino programming environment here
Download the CapSense library here
Download the Arduino sketch here
Arduino http://www.arduino.cc/
CapSense http://www.arduino.cc/playground/Main/CapSense
Great article about Capacitive sensing from Lion Precision http://www.capacitive-sensing.com/capacitive-sensor-theory.html
Wikipedia article about Capacitive Sensing http://en.wikipedia.org/wiki/Capacitive_sensing