I put this together as part of my UnoJoy project, where we're using the Arduino as a platform from which to explore how we interact with video games. You can check out more of our projects for UnoJoy at unojoy.tumblr.com, or more of our other projects at the Exertion Games Lab.
Remove these ads by
Signing UpStep 1: Materials
A pencil - the softer the lead, the better
Some 1+Megaohm resistors
Paperclips - make sure they're bare metal, not coated in plastic
Wire
An Arduino
Clear tape (optional)








































Visit Our Store »
Go Pro Today »




int firstSensor = readCapacitivePin(2);
int secondSensor = readCapacitivePin(3);
but if I touch both sensors at the same time that causes the program to hang. I used the same voltage source and added a resistor from there to pin 4 as well. Any advice?
By the way, this was a really cool project! :)
At first great thanks for this article. It has helped a lot!
I have a little problem: everything works very well with the uno, then I tried with a mega2560, I didn't change the code, and it didn't work at all. So I wondered if I should change something in the code ?!
thx !
I do not have a 1 Mohm, so i used serial 3x 330Kohms.
But it didn't work detecting anything with pencil draw.
It can detect when i touch directly the paper clip.
I got (return but serial connection) :
14 cycles (when i did not touch anything)
70 to 80 cycles when i touch the paper clip.
I used your code on an Arduino Uno R3 using pin 2 as in your example.
I'm a beginner in arduino and tried your wonderful project.
But my LED is staying lighted whatever the cutoff. I'm using an arduino MEGA2560. Should it make any difference ?
A last question about the circuit : should there be any connection between the ground of the arduino board and the drawing or myself ?
Thanks again for the great project and your help.
Julien
However, I have some Bare conductive paint from Sparkfun and it works great! I just painted a line and the circuit reacts all the way down. I am thinking of making an interactive popup book and touching the lines would be the way to interact with the page.
1. How about an explanation? How does this work exactly? How does that map to your code?
2. A non-handwritten circuit diagram would be nice
3. Why paperclips? Surely any wire is sufficient, or did I miss something. Hard to say without an explanation. See point #1.
My son has built this, and it works. What did he learn? How to download a file from the internet, and decipher a hand-drawn circuit diagram. What does he know about capacitve sensors? The same as when he started.
I hope that this doesn't sound at all snotty - but as a long-time teacher, I felt like replying...
Instructables are (to my mind) meant to be like a bit of a show and tell. It's like having a ton of geeky friends who stop by and show off what they are working on. Most of us have multiple projects going in various stages of successful operation.
I love it that your son built this circuit. But stopping there kind of misses the point. After I built it, I became curious. What does a capacitor really do? Can a stack of coins be a capacitor? So I started to experiment. I tried putting various metals on the trace - then I tried touching the + and - terminals of a 9volt battery - then I tried touching a pencil to it the lead tip, and also the metal eraser holder - then I tried different plastics - wire attached to the cement floor - and on and on. The point of a circuit like this is what can or can't it do? How could I use it? How can I learn more about capacitance by experimenting with it.
Sorry - teacher mode - anyway I hope that your son and others take the circuit and do amazing things with it! And learn by doing...
1. See step 2 in this Instructable it says this:
There are 3 ideas going on here:
1 - When you touch a conductive object, you create a certain degree of capacitance. This increases the ability of the conductive material you touched to store a charge.
2 - We can create a cheap capacitive sensor by measuring how long it takes for a piece of conductive material to go from a grounded state to a higher potential state when pulled up to that higher state through a resistor. The higher the capacitance, the longer it will take the conductive material to be pulled up to the high state.
3 - Graphite conducts electricity. You may have seen this before in the Drawdio project, where they use a pencil trace to create sound.
Therefore, if we take our conductive pencil line, pull it to ground, then try and pull it to a higher state, we can measure how long it takes, and if we're touching the drawing, it will take longer to get to a high state than usual. Conveniently, we can use the Arduino to automatically pull our trace to ground on and off. If we attach a pull-up resistor to our line, when the ground connection inside the Arduino is turned off, everything attached to the pin will start to be pulled up to VCC. So, our circuit diagram will look something like the above. We use an external pull-up resistor rather than the Arduino's internal pin pull-up resistors since we need much more resistance than the 30K ohm internal ones, otherwise, the resistance of the graphite tends to dominate and prevent the sensor from working.
2. The hand-drawn schematic as you are supposed to call it is very neat and very easy to understand if you know how to read them.
3. Paperclips are very easy to "clip" onto paper and conduct electricity so basically they are just extending the wire to the graphite. That is why they are used.
4. What did he learn? See point #1
Be thankful someone has taken hours of their time to put together such a very easy to follow and useful Instructable for your benefit, not theirs.
Next time do a little research before posting a comment like this:
"What did he learn? How to download a file from the internet, and decipher a hand-drawn circuit diagram. What does he know about capacitve sensors? The same as when he started."
I have converted my UNO into a joystick and can't upload sketches. So how would I be able to use this capacitive touch sensor to act as if I am pressing a button on the UNOjoy joystick?
One of the great things about UnoJoy is that the process is totally reversible - if you plug the UnoJoy Arduino back into your computer and put it into DFU mode again (by shorting the same pins you did when converting it into a joystick), then run the 'TurnIntoAnArduino.bat' or .command program.
If you want some sample code that uses this graphite touch sensor as joystick input, you can give this code a try:
http://code.google.com/p/unojoy/source/browse/#hg%2FExamples%2FDrawnController
Let me know if you need any more help!
1. Code that's running on the ATmega328p chip that reads in whatever input you want, then sends serial data to the communications chip.
2. A firmware for the communications chip which translates the serial data into joystick signals.
So, when developing your controller code for UnoJoy, you'll put your Arduino into the Arduino mode so you can upload code to the ATmega328p chip, then put the Arduino back into the UnoJoy mode, where it turns the serial data that the UnoJoy code on the ATmega328p is sending out into joystick signals.
While it's in Arduino mode, but running code that uses the UnoJoy library, the tool in the UnoJoyProcessingVisualizer folder takes in the serial data that the Arduino communication chip is passing through and provides a visualization of what sort of signals the code is putting out.
I am trying to make a platform game using Unity and then make a "Touch Controller" for the character and actions.
So... to confirm...
1) Upload Sample Capacitive Touch code to arduino (arduino mode)
2) Change into Unojoy and plug into pc for game controller (UNOJoy mode)
3) Play games with a "magic piece of paper."
1) Upload code to Arduino (Arduino mode)
2) Open up UnoJoyProcessingVisualizer.exe (Arduino Mode)
3) Test controller's functionality (Arduino mode)
4) Repeat steps 1-3 until satisfied with performance
5) Change into UnoJoy then plug into PC (UnoJoy mode)
6) Play games with 'magic paper'
Good luck!
So, a 'pull up' or 'pull down' resistor is a term that we use for a resistor of relatively high value (like 10K, 20K, 1M ohm) that connects a path to the voltage source or ground, respectively. We call it a 'pull up' or 'pull down' resistor because it puts a light pressure that 'pulls' the level on the line up or down if there's nothing else connected to the line.
Commonly, we'll see this used with switches - when the switch is closed, it will directly connect the pin to ground, so the level of the pin goes to 0. However, when the switch is released, the voltage on the line will bring the line back up to 1.
Heck, wikipedia is probably way better at explaining it than me:
http://en.wikipedia.org/wiki/Pull_up_resistor
At any rate, this project here relies on the fact that, after the pin switched to ground (which the Arduino does in the code), it takes a certain amount of time for the line to go back high, so we need a big value on our pull-up resistor (like 1M ohm) so that it takes a relatively long time for the voltage to go from 0 to 5v.
http://code.google.com/p/unojoy/source/browse/#hg%2FExamples%2FDrawnController
I hope it helps!
If you put in different values for that, like
int firstSensor = readCapacitivePin(2);
int secondSensor = readCapacitivePin(3);
you can read whatever Arduino pins you want, as many as you'd like.
"Capacitive Sensor on Pin 2 reads: 0"
This project is awesome,but how to put it right?
Please give me a hand.
So,if the value is too low ,it will come out [Capacitive Sensor on Pin 2 reads: 0],right?
By the way, how a 1mΩ resistor look like ? I'll got some.
Where are you touching the ground node with your body to act as the second terminal of the capacitor?
There is a ground reference that I am thinking about. One way is that USB power ground to the Arduino is connected to the same ground on which the user is standing.