Please watch this VIDEO for a live explanation.
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!
Jump Wires: Sparkfun
USB Cable: Sparkfun
Step 1: Materials
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
Step 2: Sensor Pad and Circuit
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.
Step 3: Connecting to Bare Paint
Step 4: Setting Up the Arduino
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 here.
Now that the library is installed, copy and paste the code at the bottom of this tutorial into a new arduino sketch. Load the code onto your Arduino. For more information about loading software onto the Arduino the Arduino site here.
Copy and paste the code below into a new Arduino sketch.
* CapitiveSense Library Demo Sketch
* Paul Badger 2008
* Slightly adapted by Bare Conductive 2011
* Uses a high value resistor e.g. 10 megohm between send pin and receive pin
* Resistor effects sensitivity, experiment with values, 50 kilohm - 50 megohm. Larger resistor values yield larger sensor values.
* Receive pin is the sensor pin - try different amounts of Bare Paint
* Best results are obtained if sensor foil and wire is covered with an insulator such as paper or plastic sheet
CapSense cs_4_2 = CapSense(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add Bare Paint
// CapSense cs_4_5 = CapSense(4,5); // OPTIONAL: for sensor 2, 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add Bare Paint
// CapSense cs_4_8 = CapSense(4,8); // OPTIONAL: for sensor 3, 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add Bare Paint
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
long start = millis();
long total1 = cs_4_2.capSense(30);
// long total2 = cs_4_5.capSense(30); // OPTIONAL for sensor 2
// long total3 = cs_4_8.capSense(30); // OPTIONAL for sensor 3
// Serial.print(millis() - start); // OPTIONAL: check on performance in milliseconds
// Serial.print("t"); // OPTIONAL: tab character for debug windown spacing
Serial.println(total1); // OPTIONAL: To use additional sensors,change Serial.println to Serial.print for proper window spacing
//Serial.print("t"); // OPTIONAL: tab character for window spacing for sensor output 2
//Serial.print(total2); // OPTIONAL: print sensor output 2
//Serial.print("t"); // OPTIONAL: tab character character for sensor output 3
//Serial.println(total3); // print sensor output 3
delay(10); // arbitrary delay to limit data to serial port
Step 5: Testing
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 firstname.lastname@example.org.
Step 6: General Links
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