Introduction: Turn a Pencil Drawing Into a Capacitive Sensor for Arduino
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
Wire
An Arduino
Clear tape (optional)
Step 2: Theory
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.
Step 3: Putting It Together
Now to put everything together!
First, draw something - You'll want to follow the following rules:
- Make a big filled area at the edge of the paper - this is where you'll connect your wire to the drawing via paperclip.
- Make sure all of your drawing is connected - you'll only be able to read from parts that are all touching.
- Re-trace over your lines at least once or twice - you'll want to get some nice, thick lines of graphite on the paper.
Now take one side of your wire and connect it to a paper clip - you can just strip it and wrap the wire around the clip, but you might want to solder it make sure it stays on.
Connect the wire up like so:
Then load the attached code to your Arduino.
Attachments
Step 4: Test It!
You may need to make some changes at the top of the code to get the correct cutoff value for your particular drawing, and you may need to go and re-trace over your drawing some more to get the parts of your drawing that are further away to work properly.
Once you get it working, you can take some clear tape and cover up your drawing - this will decrease its sensitivity a bit, but it will keep your drawing from smudging as people touch it.
I've put together a full video game controller with this as part of the UnoJoy project, and there will be a video over at unojoy.tumblr.com in a couple of days.

Participated in the
Make It Real Challenge
85 Comments
4 years ago
I tried it and it works with arduino, but I would like to know if there is also a version that does not directly use the AVR registers, because I would like it to work with STM32 as well.
Reply 4 years ago
Unfortunately not; the code uses the AVR registers because it uses the single-cycle read capabilities of the direct register read for timing purposes - it's basically counting the number of cycles that it takes for the pin to switch states when you touch, measuring the system's capacitance that way, so the relatively slow digitalRead() doesn't work.
7 years ago
Hi everyone! I'm really new to Arduino and I'm having problems with the code. Does anyone know why "readCapacitivePin" is not declared in this scope? And how I can fix that? Thanks you and really good project.
In function 'void loop()':
DrawnSensorExample:22: error: 'readCapacitivePin' was not declared in this scope
exit status 1
'readCapacitivePin' was not declared in this scope
Reply 6 years ago
just check "readCapacitivePin" was mention or introduce in earleir statement.. eg int x; float y;
7 years ago
Take care, if you power your arduino with a battery this won't work !! The negative pole should be grounded.
7 years ago
Excellent !
7 years ago
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 :)
7 years ago
Thanks, Kirmanimous786.You did an awesome job with this project and in showing it to us. Thank you.
10 years ago on Step 3
will this work only for arduino?pls reply
Reply 7 years ago
Only for Arduino... Let me see... How can I explain thins better... Ah... Of course:
No.
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.
It will of course be far more complicated and difficult to debug and correct, but you can do it.
Reply 8 years ago
You can use whatever mocrocontroller
8 years ago
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 ?
11 years ago on Introduction
This is a nice little project apart from a couple of basic problems.
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.
Reply 8 years ago
Im 12 by the way
Reply 8 years ago
Then teach him
Reply 11 years ago on Introduction
Hi NelloB-
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...
Reply 11 years ago on Introduction
**Just for the record coming from a 14 yo**
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 takenhours 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."
11 years ago on Introduction
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.. :/ ..
Reply 8 years ago
Try adjusting the sensitivity in the program
9 years ago on Introduction
Also, you only need one resistor or two(one 1M+, other 10-500k)?