loading

Hello everyone!

This instructable is a tutorial that will guide you on using the Capacitive touch sensors with Arduino. A Capacitive sensor is a kind of touch sensor, that requires little or no force to activate.

In this Instructable about capacitive touch sensing, I'll show you:

  • How Capacitive Sensors work
  • How to use them with an Arduino
  • How to implement them in 3 Arduino projects, that are included in this Instructable
  • How to use the CapSense library- which is used in the first two projects. I've also included the demo code and it's explanation for the CapSense library...

Skills Required for these projects are minimal:

  • Basic knowledge of electronics and arduino.
  • Soldering (optional)

So let's get started by first getting to know what this Capacitive touch sensing is all about!

Step 1: About the CapSense Library and Capacitive Sensing...

For most capacitive sensing related projects, I used the CapSense library. The arduino playground has a good explanation of the Capsense library. However, if you are a novice in Arduino, I' m pretty sure you'd understand only half of what's written there. Therefore here I have a simplified explanation...

Capacitive Sensing:

Capacitive touch sensing is a way of human touch sensing, that requires little or no force to activate. It may be used to sense human touch through more than a quarter of an inch of plastic, wood, ceramic or other insulating material (not any kind of metal though), enabling the sensor to be completely visually concealed.

Why Capacitive touch?

  • Each touch sensor requires only one wire connected to it.
  • Can be concealed under any nonmetallic mmaterial.
  • Can be easily used in place of a button.
  • Can detect a hand from a few inches away, if required.
  • Very inexpensive.

How does it work?

The sensor plate and your body forms a capacitor. We know that a capacitor stores charge. The more its capacitance, the more charge it can store.

The capacitance of this capacitive touch sensor depends on how close your hand is to the plate.

What does the Arduino do?

Basically the arduino measures how much time the capacitor (i.e the touch sensor) takes to charge, giving it an estimate of the capacitance.

The capacitance may be very small, nevertheless the Arduino measures it with accuracy.

One way of using capacitive touch in a project is to use the CapSense library. For the Capsense library, the arduino uses one send pin and any number of receive pins required. A receive pin is connected to the send pin via a medium to high value resistor.

Here are some guidelines for resistors but be sure to experiment for a desired response.

  • Use a 1 megohm resistor (or less maybe) for absolute touch to activate.
  • With a 10 megohm resistor the sensor will start to respond 4-6 inches away.
  • With a 40 megohm resistor the sensor will start to respond 12-24 inches away (dependent on the foil size). Common resistor sizes usually end at 10 megohm so you may have to solder four 10 megohm resistors end to end.One tradeoff with larger resistors is that the sensor's increased sensitivity means that it is slower.

*These resister value guideline is only for using the CapSense library. The last project doesn't use this library.

Summary: Capacitive touch sensors require little or no force to activate. The CapSense library can be used to make multiple touch sensors with Arduino.

Step 2: CapSense Library Demo Code...

Here is an explanation of the demo code for the CapSense library.

CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);

You can replace 'cs_4_2' with any other name. '4' is the send pin, '2' is the receive pin.

 void setup() {
Setup runs only once.
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);    

 // turn off autocalibrate on channel 1 - just as an example
 Serial.begin(9600);}
Begins Serial Communication at 9600baud...
long total1 =  cs_4_2.capacitiveSensor(30); 

The above statement is declared in 'void loop ()'. When using a 1M resistor, total1 will less than or about ten. When touched, it becomes more than 60...

Serial.println(total1);

Sends the value of total1 to the Serial window of the computer...

The important parts of the code are explained. This isn't the full code; the full one is in the attachment below. Skip the step if you think the code is easy.

Step 3: Projects With Capacitive Touch and Arduino...

Now that you've got an idea of what capacitive touch is (if you happened to read the previous step), let's see what we can do with it. In this instructable I will show you 3 projects incorporating capacitive touch.

Touch Operated Light:

A basic project that will help you grasp the ideas of capacitive touch and implement it in other projects. Using a relay and soldering is optional, but required if you want to ooperatehigh voltage appliances.

Proximity Sensor Switch:

Bringing your hand close to this switch will turn on or off an led. Adding a relay and soldering will enable it to operate high voltage devices, though it is optional.

3D Touchless Hand Tracker:

Tracks the position of your hand in 3 dimensions. Can be used for innumerable applications, however I have included projects with it that are simple and easy to hack, so you can use it for your own purpose. No soldering required.

Step 4: Touch Controlled Light:- Materials Required...

This is a very cheap and easy project. It gives a good idea of how capacitive touch works and how one can implement in several other applications. This simple project uses a capacitive touch sensor, that switches on and off an led, or even high voltage appliances, by touching a piece of aluminium foil.

Time: <1 hour, +1 hour for soldering relay ( optional)

Cost: Few cents, ~1$ for a relay ( excluding Arduino)

Difficulty: Very Very Easy.

Materials: (Available on RadioShack)

  • Arduino Board
  • 500K to 1M resistor
  • 220ohm resistor
  • Any colour LED
  • Foil
  • Jumper wire
  • Relay (optional)
  • Mains plug (male and female) (optional)

Step 5: Touch Controlled Light:- the Circuit

The circuit is simple. I mean so simple that you won't even need a breadboard!

Note that I have used an Arduino Mega, because right now that's the only one I have. If you are using an Uno, connect the LED to any other convenient pin. However you must make a small change in the code later. See the next step.

Follow the pictures for the circuit.

  1. I connected the led and 220ohm resistor in series across pin 42 and ground.
  2. I have used pin 4 as the send pin and pin 2 as the receive pin on the Arduino.
  3. There is a 1M resistor across these pins. The foil is connected to the receive pin, i.e pin 2.

Step 6: Touch Controlled Light:- Arduino Code...

Now to the programming part. The code uses the CapSense library (download here), that takes care of capacitive sensing. If you're not familiar with the process of installing a library, check out this awesome tutorial:

Installing An Arduino Library - Learn.SFE

The code is simple and easy to understand. Simply copy this code and paste it a a blank Arduino wwindow. Change the led pin if required. Then upload...

#include <CapacitiveSensor.h>

int led = 42;                                          //change '42' to any desired pin...long time = 0;
int state = HIGH;

boolean yes;
boolean previous = false;

int debounce = 200;

CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired// To add more sensors...//CapacitiveSensor   cs_4_6 = CapacitiveSensor(4,6);        // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil//CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foilvoidsetup()                    
{
   cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);  //Calibrate the sensor... 
   pinMode(led, OUTPUT);
}

voidloop()                    
{
    long total1 =  cs_4_2.capacitiveSensor(30);
    
    if (total1 > 60){yes = true;}
    else {yes = false;}    
    
    // to toggle the state of state
    if(yes == true && previous  == false && millis() - time>debounce){
      
       if(state == LOW){
         state = HIGH;
       }
       else 
         state = LOW;
         time = millis();     
       
    }
       
   
      digitalWrite(led, state);
      previous = yes;

      Serial.println(millis()-time);
      delay(10);


}

Step 7: Touch Controlled Light:- Adding a Relay...

So you got a touch controlled LED. So what? You can make the project a tad bit more useful by controlling the appliances like lights and fans with touch. And fortunately, you only need to add a relay to the Arduino to do this.

What is a Relay ?

A relay is an electrically operated switch. Usually relays use an electromagnet to mechanically operate an isolated switch. It's main function is to use a small voltage to switch on/off a high voltage or high current separately. It's handy for controlling mains appliances with small circuits or micro controllers.

To learn more about relays, check out this great Instructable - How Electronic Switches Work For Noobs: Relays and Transistors

The Circuit:

The Arduino cannot supply enough current to operate a relay, therefore you'd need a BC547 transistor. The transistor amplifies the Arduino's current to activate the relay. For help in understanding check this helpful video - How to Control Relays with Arduino

I have provided the circuit diagram for the transistor and relay. There is a Fritzing breadboard diagram too, to help you understand the connections.

After that prepare the male plug as shown in the pictures above...

Step 8: Touch Controlled Light:- Making a Box for the Relay...

I used a plastic box of 5*2*2 inches for housing the relay and wires. It may be a bit too big, but good enough for demonstration. My main intention was to keep high voltage wires separate from the Arduino and my body.

Prepare The Box:

Cut out a square hole from the lid of the box to fit the female plug. Make holes for the screws, and then fit the plug. Stick the relay to the bottom of the box.

Make Connections:

The circuit involving high voltage is very simple. Follow the pictures and their tags, or the following steps:

  1. Relay's COM to one terminal of the mains supply.
  2. Relay's NO to one terminal of the appliance.
  3. The other terminal of the mains to the 2nd terminal of the appliance.

Step 9: Touch Controlled Light:- Add the Touch Sensor and Arduino...

Stick a piece of foil on the box with tape as shown above. This is connected to the Arduino's receive pin (pin 2 in my case). The "led pin", or pin 42 in my case, is connected to the transistor.

Step 10: Touch Controlled Light:- Finished!

Connect the male plug to the mains outlet, and plug in the appliance you want to control to the box. Power up your Arduino with a battery.

There you have it - your own touch controlled light! You can use more relays and touch sensors to control more appliances, or incorporate it in a home automation system. For now I use it to control my desk lamp, and it works quite well.

Here's a video showing the working of the touch switch...

Also I have a video showing the prototype working...

Hope you don't mind the blast in the end :P.....

Step 11: Proximity Detecting Light Switch

Bringing your hand close to the switch, or simply waving your hand over it will turn on or off a light. It is actually very similar to the "Touch Controlled Light" in the previous steps. In fact, the latter can be easily modified to make this proximity detecting light switch...

Time: Total <1 hour, +1 hour for optional soldering

Cost: ~1$, excluding Arduino

Difficulty: Easy

Materials Required:

  • Arduino Board
    • 5.6M resistor
    • 220ohm resistor
    • Any colour LED
    • Foil
    • Jumper wire
    • Relay (optional)
    • Mains plug (male and female) (optional)
  • Step 12: Proximity Detecting Light Switch:- the Circuit...

    The circuit is simple, it's just a modification of the "Touch Controlled Light". In fact the only thing you have to change is a resistor; this time you have to use a ~5M resistor across pins 2 and 4 of the arduino.

    Step 13: Proximity Detecting Light Switch:- the Code....

    Here the code is similar to the "Touch Controlled Light". You only have to change the debounce time in the code, and adjust some other values with trial and error...

    Copy this code and paste it in the Arduino window....

    #include <CapacitiveSensor.h>
    
    int led = 42;                                          //change '42' to any desired pin...
    
    long time = 0;
    int state = HIGH;
    
    boolean yes;
    boolean previous = false;
    
    int debounce = 200;
    
    CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
    
    // To add more sensors...
    //CapacitiveSensor   cs_4_6 = CapacitiveSensor(4,6);        // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
    //CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
    
    void <strong>setup</strong>()                    
    {
       cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);  //Calibrate the sensor... 
       pinMode(led, OUTPUT);
    }
    
    void <strong>loop</strong>()                    
    {
        long total1 =  cs_4_2.capacitiveSensor(30);
        
        if (total1 > 60){yes = true;}
        else {yes = false;}    
        
        // to toggle the state of state
        if(yes == true && previous  == false && millis() - time>debounce){
          
           if(state == LOW){
             state = HIGH;
           }
           else 
             state = LOW;
             time = millis();     
           
        }
           
       
          digitalWrite(led, state);
          previous = yes;
    
          <strong>Serial</strong>.println(millis()-time);
          delay(10);
    
    
    }

    Step 14: Controlling High Voltage Appliances...

    To control high voltage appliances, a relay is required. Follow the same instructions for setting up the relay as in the previous project...

    Step7- Adding A Relay

    Step 15: Touchless 3D Controller

    This 3D controller will track the position of your hand in 3 dimensions. It is based on Capacitive touch sensing. Like the previous project, the Proximity Detecting Light Switch, the touch sensor will be able to sense your hand from a few inches away.

    This is project is inspired by kylemcdonald's awesome Instructable- DIY 3D Controller. Have a look at his Instructable too to get an idea of this 3D controller...

    There is a lot of stuff you can do with this 3D controller, for example, as a computer mouse, to control a 3D animation scene, control LED cubes, and a lot more. But of course, they aren't that easy and cheap to do.

    Therefore I have got a simple yet cool project apt for beginners- A 3D Tracker Controlled RGB LED. Basically you can control the colour of an LED by moving your hand in different positions. Didn't get it? Go on to the next step for more....

    Step 16: How It Works, and Materials...

    This 3D controller has 3 touch sensors, that respond from a few inches away. By judging the distance from each sensor the Arduino can calculate the x, y and z coordinates of your hand.

    The RGB LED has 3 colours: red, green and blue. Each colour's brightness depends on respective coordinate of the hand. For example, the lesser the x coordinate (the closer my hand is to the right sensor), the brighter the red colour of the rgb LED.

    Time: 1 - 1.5 hours

    Cost: <$1, excluding Arduino...

    Difficulty: easy.

    Materials Required:

    • Aluminium foil
    • Arduino Board (I recommend the Uno)
    • 10k ohm resistors x3
    • 220kohm resistors x3
    • 220 ohm resistors x3
    • Wire
    • RGB LED

    Step 17: Preparing the Touch Sensors....

    We need three separate pieces of foil, with dimensions of about 8*8 inches. One piece of foil is stuck on a thick Styrofoam(thermocol) base. Slits are made on the Styrofoam on 2 adjacent sides of the foil, as show in the pictures above.

    The other two pieces of foil are stuck on mountboard (which is white cardboard).

    These two pieces of mountboard are inserted into the slits in the Styrofoam, perpendicular to each other and the Styrofoam, as shown in the pictures above.

    To make the whole thing sturdy, I used a small rectangular piece of mountboard to hold the two mountboards with the foil together. The pictures above and their tags will definitely help a lot.

    Step 18: The Circuit...

    Connect a wire to each touch sensor with insulation tape. Then assemble the circuit on a breadboard, with the help of the Fritzing breadboard layout above.

    Step 19: Upload the Code...

    The code is provided in the attachment below. Just click it and copy and paste the code into the Arduino code window.

    Before hitting upload, be sure to make changes to pins, if required.

    Calibrating the Touch Sensors..

    After uploading the code, open the Serial Monitor, with the Arduino still connected. You will see many lines of values rolling in, with each line having 3 values representing each touch sensor. Touch any one touch sensor (you must know which one you are touching), and see its corresponding value on the Serial Monitor.

    You will see this line in the code before void setup (){

    int maxval = 20;

    Change 20 to the value you got after touching one of the sensors.

    Then upload the code once again. Moving your hand inside the 3D controller will produce a variety of colours.

    Important Note: The below code only works for Arduino Uno (and probably Leonardo) compatible boards. I tried the Mega and it didn't work, because it has very different 'PORTS' (even I found it hard to understand at first- this is for the more experienced blokes)....

    Summary: Upload the code, adjust the "maxval" variable and upload again. Using an Arduino Uno or clone is recommended.

    Step 20: Conclusion...

    Those are just 3 projects you can do with Capacitive touch. Hopefully they will give you a solid idea on using touch sensors to make awesome things. Don't just stop here- the stuff you can do with Capacitive touch sensing are endless: Touch keypads, track pads, Touchless computer mouse, touch controlled clock are only a few of the countless ideas I can think of.

    Going Further.....

    You could do more with the projects I've shown. For example, using the 1st project's idea, make a touch switch board for controlling several lights and fans in a room. Or maybe incorporate it in a home automation project.

    With the idea of the proximity detecting light, try making an automatic desk lamp, that senses your presence.

    With the 3D controller, try making a 3D mouse with an Arduino Leonardo. Or use a Processing programme to communicate with the 3D controller.

    Other Tutorials and more...

    playground.arduino.cc/Main/CapSense

    Hackaday Tutorial

    Here's a great video (its not mine though) just a simple Capacitive touch tutorial, which I have also covered. A video may make things clearer though....

    Step 21: Please Comment and Express Your Opinions...

    With your help I can certainly make this Instructable better..

    Very useful. Will try it. Any idea if the intensity of an LED strip can be controlled using one touch sensor? Like, the closer you put the hand, the brighter the strip gets?
    <p>Yes, as Raitis says, it is possible. See step 2 of this instructable - there is an attachment containing the CapSense code. Download that. Now modify it. </p><p>In void loop(){}, add this line after the Serial.print statements...</p><p>int x = map(total1, 100, 800, 0, 255);</p><p>analogWrite(13, x);</p><p>In void setup() declare pin 13 as output.</p><p>Then hit upload. For calibrating/troubleshooting you should have some basic Arduino knowledge.</p><p>Now add a resistor of about 10M ohms between pin 2 and 4 (i.e. the send and receive pins)</p><p>The closer you move your hands to the foil, the brighter the onboard led on pin 13 will be.....</p>
    <p>Thanks again Tim for the great instructable! Was the inspiration for my own first instructable:</p><p>https://www.instructables.com/id/Elven-Magic-Orb/</p>
    <p>Um... Not really.... But you've got an awesome i'ble there ! Really I see no reason for it to get only ~30 views....???:-(</p>
    <p>Yes, totally doable, the output has quite a wide range of values depending on the resistor used and size of the surface. Source: I'm currently working on a project which uses this library.</p><p>I believe a code provided in <a href="http://dev.mikamai.com/post/91267125014/attiny85-based-capacitive-sensor-led-switch" rel="nofollow">this page</a> may be useful for your application.</p>
    <p>This project was very easy to make because the instructions are nicely detailed. I put the aluminum foil inside a book to demonstrate that touching is not needed. After messing with this project I discovered that I only need to touch the insulation on the wire from pin 2 with my thumb and finger to light the lamp between the pin and the resistor, or touch the wire going to the foil. A long touch will cause the LED to blink.</p><p>Thank you for this project.</p>
    That looks great! Even I got the blinking problem. But a quick touch did the job and so I didn't worry.<br>However I would like it if someone would come up with a solution.... <br><br>
    <p>Hi, I have downloaded the code as is, and got the error massage:</p><p>expected unqualified-id before '{' token</p><p>any ideas why? any help will be much appreciated... </p>
    <p>I was having the same problem, looks like this segment of code:</p><p>cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); //Calibrate the sensor... </p><p> pinMode(led, OUTPUT);</p><p>should be in the void setup() function.</p><p>I also had to declare long time = 0 (it looks like it got commented out in the original) and add a space so &quot;voidloop&quot; is now &quot;void loop&quot;</p><p>Hope this helps!</p>
    <p>I'm getting the same error message (the only code line I changed was the initial LED). Does anyone know any solutions?</p><p>Thanks</p>
    <p>hi, I wanted to know if I can connect multiple sensors to one board and use them or do I have to use seperate board for each sensor? thanks</p>
    hey i wanted to make a touch keyboard and i have this idea that if we convert this 3d sensor to a 2d sensor than can we actually know where my hand is placed on the keyboard and according to that information we can give a input to the computer (keyboard.press)but i am not good at programming so can anyone pls help me out here ???? any help will be appreciated.pls help because i cant understand this code and i don't understand where the code for the sensor meets the code for the software in the computer ,sos
    hey i wanted to make a touch keyboard and i have this idea that if we convert this 3d sensor to a 2d sensor than can we actually know where my hand is placed on the keyboard and according to that information we can give a input to the computer (keyboard.press)but i am not good at programming so can anyone pls help me out here ???? any help will be appreciated.pls help because i cant understand this code and i don't understand where the code for the sensor meets the code for the software in the computer ,sos
    <p>millis() - time&gt;debounce</p><p>better change to:</p><p>(millis() - time&gt;debounce || millis() &lt; time) </p><p>as millis() go back to zero after 50 days and if you not will touch it in 50 days :) got locked on next 50 days or until reset.</p>
    <p>I have just jumped into the world of Arduino. Good stuff. I am trying to write the code (Still figuring out C++) so that I have two touch sensors. When both are touched at the same time via say two people holding hands I can turn on something else. This is for a prop in an escape room. Any help is appreciated.</p><p>Steve</p>
    i wish to add many sensor using few arduino pins can i use this code with few modification using analog input to oprate many sensors
    <p>Hi... can i use 5 ports with CapSense sensors? or is not recomended or the Arduino have some kind of limitation for that?</p>
    <p>I tried the 3D touch sensor with an UNO and I downloaded your code for it and included the CapacitiveSensor Lib and didn't work. It said Porth was not declared and PINH was not declared</p>
    <p>is there anyway that i can improve the capsense in salt water. Am doing this project where i want to implement the capsense as a kill switch but, is not working well in the salt water environment?</p>
    I think it wont work because salt water is a good conductor. So there is no capacitance to be measured (actually there is, but it can't be used reliably for touch or distance measurement). A simple resistive switch should do the job!
    So am working on a project called RC Ski. I don't if you know about wakeboarding, well how it work is there is a person driving the Jetski and someone is in the back riding the wakeboard. Well am doing this project where you don't need a person driving the Jetski, the person on the wakeboard Is controlling also the Jetski. I have some safety issues that am trying to implement, for example if the person falls off from the wakeboard we need to send a signal to the Jetski so that it can shut off. I don't know what kind of sensors I can use to implement this issue. What is a resistive switch? I tried hall effect sensors, it works but u require a lot of them, and that not really what I want. <br>
    <p>How can We Use this without Ground touch</p>
    <p>hi, i want to ask, i already follow your step. but it is no function correctly, the lamp switch but does not switch off or on when i touch the switch</p>
    <p>Hi, is there any way to make the LED turn on when the sensor is touched and then turn off itself without a second touch? I thought using a delay might work, but cant see where in the code this may go?</p>
    looks nice...
    <p>I have done it, pasted the code, and used a little piece of foil(2x2 cm), and 2x220 Ohm resistors for foil and later I have tried also with 2.2kOhm (using arduino Uno). The diode is all the time on. What have I done wrong?</p>
    <p>Hey, really nice instructable there. I made the touch switch and it worked perfectly. I'm doing a project where the capacitive touch is replaced by voice recognition. I've used the same relay-Arduino circuit as yours and it works fine for one device. But, when I did the same thing with two devices connected in parallel it wouldn't work. Any suggestions on using multiple devices?</p>
    <p>For simplicity purposes I would suggest to use touch sensor something similar to what is shown in this video: <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/WdfA57TUyII" width="500"></iframe></p><p>Waaaaay simplier, no?</p>
    <p>thanks for your 'ible...will use it in a kinetic sculpture, when I'm done, I (hope) I will post an image.</p>
    <p>Hi DangerousTim!</p><p>I'm trying to build the 3D RGB Capacitive Controller from your awesome instructable, I'm using an Arduino UNO. I get the following errors: <br><br>FF70FCLHZS8T444.ino: In function 'long int time(int, byte)':</p><p>FF70FCLHZS8T444:64: error: 'PORTH' was not declared in this scope</p><p>FF70FCLHZS8T444:66: error: 'PINH' was not declared in this scope</p><p>I tried defining them, by using 'int PINH', and 'int PORTH', while it remove's the errors, the setup doesn't seem to do anything. Nothing is displayed in the Serial Monitor.</p><p>I'd be really thankful if you'd help me out! :)</p>
    <p>Hey this is great!! I was wondering if there is a way to do this without having to use a microcontroller. An absolute touch sensor to act as a switch in a simple circuit, but not a button like this <a href="https://www.instructables.com/id/Three-Fabric-Buttons/step4/Making-holes/ " rel="nofollow">https://www.instructables.com/id/Three-Fabric-Buttons/step4/Making-holes/ </a> Thanks!!</p>
    <p>hi ,that's a good instructables ,i have tow question,please </p><p>1.if (total1 &gt; 60){yes = true;} ,how to get the &quot;60&quot; not 30 or 100</p><p>2.long total1 = cs_4_2.capacitiveSensor(30);if this sentence is run in the setup() ,will get another value .why</p><p>thanks </p>
    <p>yay25k + views</p>
    <p>Can this be done with an ATTiny85?</p>
    Yes, provided you know how to use Arduino as an ISP and program an attiny... Better look it up with Mr. Google though...
    Smart idea! I really like this project. Thanks for shearig :)
    In the basic touch light code, you used digital output pins 4+2 for the sensor. Would it be possible to use the analog input pins instead? If so how would I do that? Would I have to change the code? Also, it said that if I wanted, say two, sensors instead of one that I would have to use pins 4+6 rather than 4+2. How would I set up the output? Instead of controlling just pin 42, how do I control, say pin 40, as well? I'm very inexperienced with arduino, if you couldn't tell ;) Thanks
    yes you can use analog pins instead! Instead of Capacitive Sensor (4,2); u can use Capacitive Sensor (4, A0); . In this way u can use any analog pin...<br><br>also u can change <br>int led = 42;<br><br>by replacing 42 by any pin number required
    <p>Awesome! OK, so I could just change 42 to any other pin. How could I make two sensors control pins 42+44? I want to have two sensors, each with a corresponding relay. </p>
    Kudos Tim... good instructable. .. many salutes for giving a rather exhaustive instruction... <br>btw, which part of the beautiful world are you from? curious I asked because I saw a very familiar plug socket we see in India. .. :)
    <p>You guessed it right. BTW that male plug you see is one of the worst quality plugs I have ever used... :-) </p>
    does humidity drastically affect the capacitance?
    <p>Thats A great question! Well, I don't think they will affect this type of sensor greatly, but I'm not sure. However according to Wikipedia, some humidity sensors use Capacitive sensors.....</p>
    <p>Thank you so much, easy and simple.</p>
    <p>Hey there ! first of all that's impressive !</p><p>I'm getting one problem with the CapacitiveSensor library. I installed the library ( in the library folder ) but when I try to restart the IDE, it won't respond and eventually gives the error &quot;error while starting the application&quot;. The IDE works fine when I remove the library from it's main folder. Please guide me through it. Thanks.</p><p>PS : IDE version : Arduino ERW 1.0.5 </p>
    <p>I had some problems installing it too. Make sure that:</p><p>1. The file downloads correctly</p><p>2. You have unzipped the file- its quite easy; just right-click the folder, chose extract all files.</p><p>3. Move the file to the correct location:</p><p> Arduino &gt; Libraries</p><p> (Capital &quot;L&quot;)</p><p>4.Check the name of the file. It shouldn't have spaces or dashes. Underscores are fine.</p><p>These tutorials will help</p><p><a href="https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use/installing-a-library" rel="nofollow">https://learn.adafruit.com/adafruit-all-about-ardu...</a></p><p>For Mac users</p><p><a href="https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAA&url=http%3A%2F%2Farduino.cc%2Fen%2FGuide%2FLibraries&ei=ERMlVKa8IpCn8AXtg4DIBg&usg=AFQjCNFl1Zx-Eea8bdk2hQK_nlcNCBXr0g&bvm=bv.76247554,d.dGc" rel="nofollow">https://www.google.co.in/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;...</a></p><p>Hope this helps...</p><p>BTW your gesture controlled robot is Awesome!!!</p>
    <p>Thanks for the response ! :)</p><p>The problem was that , my &quot;libraries&quot; folder had too many libraries. After deleting a couple of unused libraries it worked fine. </p><p>And the idea of using three Aluminium foils to track 3D movement of hand is superb ! :D Why don't you enter this instructable in any contest ? </p><p>While using the Serial monitor I noticed that the readings are not constant and they keep on fluctuating. Is there any way to counter this problem ?</p>
    <p>I'm not very sure. Grounding the Arduino with help. Maybe try adding some code to calibrate it...</p>
    <p>sorry wrong link for Mac users see</p><p><a href="http://arduino.cc/en/Guide/Libraries" rel="nofollow">http://arduino.cc/en/Guide/Libraries</a></p>

    About This Instructable

    227,932views

    599favorites

    License:

    Bio: Linux n00b, hacker
    More by DangerousTim:ESP8266 Desktop Clock (WiFi Synchronised!) Linkit ONE GPS Tutorial Linkit ONE Setup Guide 
    Add instructable to: