Creating an interactive drawing with arduino

I have to develop new arduino projects each week for my young pupil, who is passionate about electronics and hardware. For that, I found our last project creative and interesting, and I bet some of you can use it as a geek experiment.

What we need here is graphite based pencils (or directly graphite, works better), arduino, resistors, a led, a metallic clip, and a white regular paper. How does it works?

First we should know how this works. In arduino, we can use several sensors as INPUTS, such as a button, a light sensor, an humidity sensor, etc. But we can also attach home-made INPUTS using conductor materials. Steel and metal are common conductors materials (you can try this experiment with a coin, too) and so is graphite .

For making this work in arduino, we are using a special library called CapacitiveSensor04 . Once our library is added, we can start designing the circuit. This is an example with steel paper, works the same with graphite. Only draw something (very dense), attach a paper clip to the drawing (be careful, it should be a single-line drawing) and a cable to the paper pin, which is the one connected to the resistor + 4 and 2 pins.

And this is our code:

CapacitiveSensor capSensor = CapacitiveSensor(4,2);

int threshold = 1000;
const int ledPin = 12;

void setup() {

    pinMode(ledPin, OUTPUT);


void loop() {

    long sensorValue = capSensor.capacitiveSensor(30);
    if(sensorValue > threshold) {
        digitalWrite(ledPin, HIGH);
    else {
        digitalWrite(ledPin, LOW);


We might have to calibrate the threshold, in which case you will only have to open the Monitor and test. And… tadaah! interactive drawing hat lights a led. You can now do other things. Just experiment!

In case you are a tutor, teacher or parent, here ‘s the content of my class in spanish ready for the students (answers, incomplete code for them and complete code with comments for the teachers and activities).

The Practical Developer稿源:The Practical Developer (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合技术 » Creating an interactive drawing with arduino

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录