Mar 16, 2016

Arduino Project # 2 - Touch-less Switch

arduino project

Arduino Project – Touch Me Not

I modified the Arduino project from the Arduino Starter Kit (Touch Sensor Lamp). Now it lights up an LED when your hand is close on the aluminium foil (without even touching it). This can be used as a ‘Touch-less Switch’. I just did it because it seemed pretty cool to me! How is this arduino project useful? Let me know how you think this can be useful, in the comments below.
 

How does it work?


 

Things Required

1) Arduino Uno
2) 1 LED (any color)
3) A 200 ohm resistor
4) A 1 Mega ohm resistor
5) Aluminium Foil
6) Capacitive Sensor Library (Note: You need to unzip this file and put it inside the Arduino’s Library Folder. If you don’t know how to do that, you may this tutorial)
 

Build the Circuit

arduino project
In the Circuit:

* The LED and the 220 ohm resistor are connected to Pin 12 on the Arduino (and ofcourse to the Ground)
* The 1 Mega ohm resistor is connected between Pin 2 and 4.
* The Aluminium Foil is connected to Pin 2.

[If you want to use other Pins then don;t forget to change those pins in the code below. I suggest you use the same Pins as shown in the circuit figure above so that you don’t have to change anything in the code]

 

Code

After you’re done making the circuit, comes the fun part: coding! I love to code the circuit I made myself. The code is short and simple.

 

#include <CapacitiveSensor.h>

// pin 4 sends electrical energy
// pin 2 senses senses a change
CapacitiveSensor capSensor = CapacitiveSensor(4,2);

const int ledPin = 12;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}

void loop() {
long sensorValue = capSensor.capacitiveSensor(30);

Serial.println(sensorValue);

if(sensorValue > 15) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
delay(10);
}

 

Now, all you have to do is connect your arduino to your PC and upload the code. Your Arduino Project is finish, and you have a working capacitive sensor that can act as a touch-less switch. (Follow me on Google+ to ask any questions)

Article Tags

Related Posts

css.php