Turn a Pencil Drawing Into a Capacitive Sensor for Arduino

179,513

396

90

Posted

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.

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.

2 People Made This Project!

Recommendations

  • Spotless Contest

    Spotless Contest
  • Science of Cooking

    Science of Cooking
  • Microcontroller Contest

    Microcontroller Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

90 Comments

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

just check "readCapacitivePin" was mention or introduce in earleir statement.. eg int x; float y;

Take care, if you power your arduino with a battery this won't work !! The negative pole should be grounded.

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 :)

Thanks, Kirmanimous786.You did an awesome job with this project and in showing it to us. Thank you.

will this work only for arduino?pls reply

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.

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 ?