Did you know?  You can make pencil drawings reactive to touch for use with your projects!  It's really easy, and gives you a lot of flexibility in making interfaces for whatever microcontroller project you're making.

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.

Step 1: Materials

You'll need the following:

A pencil - the softer the lead, the better
Some 1+Megaohm resistors 
Paperclips - make sure they're bare metal, not coated in plastic
An Arduino
Clear tape (optional)
<p>Hi everyone! I'm really new to Arduino and I'm having problems with the code. Does anyone know why &quot;readCapacitivePin&quot; is not declared in this scope? And how I can fix that? Thanks you and really good project.</p><p>In function 'void loop()':</p><p>DrawnSensorExample:22: error: 'readCapacitivePin' was not declared in this scope</p><p>exit status 1</p><p>'readCapacitivePin' was not declared in this scope</p>
<p>just check &quot;readCapacitivePin&quot; was mention or introduce in earleir statement.. eg int x; float y;</p>
<p>Take care, if you power your arduino with a battery this won't work !! The negative pole should be grounded.</p>
<p>Excellent !</p>
thanks for the code, Im begginer but is usefully for me to read code and try to understood it all, Im trying to descifrate the readCapacitivePin funtion :) if somebody can provide me some code more easy to lear based on it , it could be great but thanks for ur time and code :)
<p>Thanks, Kirmanimous786.You did an awesome job with this project and in showing it to us. Thank you.</p>
will this work only for arduino?pls reply
<p>Only for Arduino... Let me see... How can I explain thins better... Ah... Of course:<br><br>No.<br><br>Indeed Kirmanimous786 already told you that. What he did not tell you is that if you use a 555 clock signal chip and yo hook it up correctly, you could thoretically use it WITHOUT any microcontroller. <br><br>It will of course be far more complicated and difficult to debug and correct, but you can do it.</p>
You can use whatever mocrocontroller<br>
<p>This experiment looks really cool but when I try to reproduce it with the same program, it doesn't work. I even tried touching the leg of the resistor to see if it wasn't a problem with my drawing. Do I need to tweak with the resistor's value or the program itself ?</p>
This is a nice little project apart from a couple of basic problems. <br> <br>1. How about an explanation? How does this work exactly? How does that map to your code? <br> <br>2. A non-handwritten circuit diagram would be nice <br> <br>3. Why paperclips? Surely any wire is sufficient, or did I miss something. Hard to say without an explanation. See point #1. <br> <br>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.
Im 12 by the way
Then teach him
Hi NelloB- <br>I hope that this doesn't sound at all snotty - but as a long-time teacher, I felt like replying... <br>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. <br> <br>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. <br> <br>Sorry - teacher mode - anyway I hope that your son and others take the circuit and do amazing things with it! And learn by doing...
<strong>**Just for the record coming from a 14 yo**</strong><br> <br> <strong>1. See step 2 in this Instructable it says this: </strong><br> <br> <em>There are 3 ideas going on here:<br> 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.<br> <br> 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.<br> <br> 3 - Graphite conducts electricity. You may have seen this before in the Drawdio project, where they use a pencil trace to create sound.<br> <br> 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.</em><br> <br> <strong>2.</strong> The hand-drawn <strong><em>schematic </em></strong>as you are supposed to call it is <em>very</em> neat and <em>very</em> easy to understand if you know how to read them.<br> <br> <strong>3.</strong> Paperclips are very easy to <em>&quot;clip&quot;</em> onto paper and conduct electricity so basically they are just extending the wire to the graphite. &nbsp;That is why they are used.<br> <br> <strong>4.</strong> What did he learn? See point #1<br> <br> Be thankful someone has taken<em> <strong>hours of their time</strong></em> to put together such a very easy to follow and useful&nbsp;Instructable&nbsp;for <strong>your</strong> benefit, not theirs.<br> <br> Next time do a little research before posting a comment like this:<br> &nbsp;<br> <em>&quot;</em><em>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.&quot;</em><br>
hello.. your project is amazing,, i tried it but my led is constantly glowing.. i dont knw what is the matter,, i checked all connections,, dont knw from where it is gettin the charges.. :/ ..
Try adjusting the sensitivity in the program
<p>Also, you only need one resistor or two(one 1M+, other 10-500k)? </p>
I used two 510 k ohm resistors, it worked good for me
Thanks! This is a great project. I'm now trying to make a concealed lock with this principle!
<p>Very nice tutorial! I am having a lot of problems trying to add multiple sensors to different pins on the arduino. I'm very confused on what to change in order to get the sensors to work separately. Any help is appreciated!</p>
<p>im not really good in these things but i think for this line </p><p>int capSensePin = 2;</p><p>u can change like </p><p>int capSensepin1 = 1;</p><p>int capSensepin2 = 2;</p><p>and then write codes for 2 pins when u need to type capSensePin type capSensepin1 or capSensepin2</p><p>also u need another resistor for next sense. </p><p>sorry for my bad english.</p>
<p>I altered a little bit after I made it </p><p>I connected the wire to a small plant (inside the soil) and surprisingly the cycle changes when I touched the leave. </p>
<p>Hey, This is exactly what I'm trying to do, could you please help get mine working? could you share your code with me please?</p>
<p>Hello! I'm very new to the Arduino, but I really like your project! I was wondering how someone could do this but with sound also? Could it be activated in a way that every time you touch the drawing a chord or a note plays? Possibly through a phone or computer?</p>
Something like this lets you make sounds directly with your Arduino:<br>https://www.adafruit.com/products/94<br>Otherwise, you might look up Processing and how to use that with Arduino to have your Arduino drive sounds on a computer. Hope it helps!
<p>hellooooo:)</p><p>im just starting to understand the Arduino and everything works except that the LED that's integrated in my Arduino works but not the one I have on my breadboard. The rest works perfectly:)</p>
<p>clever idea, and inventive with that, well done.</p>
<p>I tried but I have no results =(</p>
<p>My students will love it!! Thanks :)</p>
<p>How about the length of the drawings, it should have a limit or I can draw up my entire lines, no matter the length of it? I need just to link it?</p>
<p>You should only need one resistor per line, but bump up the value the longer the line gets. The longer the line, make sure you're making it a thick line, going over it a bunch of times with the pencil. Graphite on paper isn't a great conductor, so laying it on thick helps a lot.</p>
<p>Hey, thanks for answers, I'm looking into it right now, I don't know if I'm making mistakes, but should the &quot;touchedCutoff&quot; threshold be higher when using long wires to connect to the drawing?? I've a short wire and the touchedCutoff value is 20, but when I connect a longer wire, it keeps turning on while I'm managing the wire itself... I think it's getting the threshold... is it right or some kind of strange?</p>
<p>How would you do this with a RGB LED?</p>
<p>is there a way to do this analog?</p>
<p>Awesome...I tried it on an AVR microcontrollor also..:)</p>
Hey Alan! <br>At first great thanks for this article. It has helped a lot! <br>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 ?! <br>thx !
<p>Something even simpler, leave the code as it is, connect the &quot;read cable&quot; it to PIN 19, not PIN 2.</p><p>The reason is the readCapacitivePin method/function manipulates the ports directly from the AVR chip, the PD2 port is wired to PIN 2 on the Arduino UNO and to pin 19 on the Arduino Mega2560.</p><p>If you want to change the code I would recommend you reading a &quot;port manipulation tutorial&quot; before doing so. If you want to find one remember that Google is your friend for stuff like that.</p>
Which pins I have to use, and where do I have to connect them? I can't see it very well at the photo :P... <br>
Awesome article! I am having some trouble with adding multiple different sensors, and I did: <br> <br>int firstSensor = readCapacitivePin(2); <br>int secondSensor = readCapacitivePin(3); <br> <br>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?
Hello, I have recently tried out this from a using a capsense PCB and apparently the wires at some level also carry a degree of capacitance.Is there anyway to filter the circuit more in order to get a better output? <br> <br>By the way, this was a really cool project! :)
Hey your project is very good and interesting. But when I tried it the LED is always on and when I touch the paper clip or writing it flickers/blink. I tried to change some of the code but it doesn't work. Do you know why I am having this problem? Thank You.
Thanks for the great article, and for sharing the great results to your effort
I just try last night but i did not work as a except. <br>I do not have a 1 Mohm, so i used serial 3x 330Kohms. <br> <br>But it didn't work detecting anything with pencil draw. <br>It can detect when i touch directly the paper clip. <br> <br>I got (return but serial connection) : <br>14 cycles (when i did not touch anything) <br>70 to 80 cycles when i touch the paper clip. <br> <br>I used your code on an Arduino Uno R3 using pin 2 as in your example. <br>
If you're getting a response by touching the paper clip, then the circuitry is working. There may be an issue with the thickness of your pencil trace - I find that going over the line multiple times is sometimes necessary, and you can test the conductivity of your trace by touching the trace, then, holding the paperclip by the insulated wire, touching the paperclip to different parts of the trace and seeing if it still triggers the sensor.
When I built a Drawdio I experimented a LOT with different pencils, and there is a BIG difference in the way they respond with a circuit like this. I went to the art store and bought soft lead sketching pencils, and a 4b or 6b worked great, much better than a #2 or HB. The problem is not difficult to solve, experiment a bit!
Hi <br>I'm a beginner in arduino and tried your wonderful project. <br>But my LED is staying lighted whatever the cutoff. I'm using an arduino MEGA2560. Should it make any difference ? <br>A last question about the circuit : should there be any connection between the ground of the arduino board and the drawing or myself ? <br> <br>Thanks again for the great project and your help. <br>Julien
I got the circuit to work first try, but only by touching the paperclip. I think I need a better pencil to make it work with the graphite. (I tried various values to increase sensitivity but no go with graphite). <br> <br>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.
Hello, awesome idea. <br>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?

About This Instructable




More by alan.chatham:Remote-Control Thunderclouds Turn a pencil drawing into a capacitive sensor for Arduino Play Guitar Hero with a Real Guitar 
Add instructable to: