Pages

Sunday, May 25, 2014

Touch-less Switch

I modified the 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'. How is it useful? Well, I just did it because it seemed pretty cool to me! The circuit schematic and the code can be found below:





CIRCUIT:

From Arduino Starter Kit (Touchy-feely Lamp)

NOTE: YOU HAVE TO DOWNLOAD THE CAPACITIVE SENSOR LIBRARY FIRST AND PUT IT INSIDE THE ARDUINO'S LIBRARY FOLDER. DOWNLOAD IT HERE: http://arduino.cc/playground/Main/CapacitiveSensor


CODE:

/*
TOUCH-LESS SWITCH
Modified Version of the Code - Touch Sensor Lamp
from the Arduino Starter Kit.
Modified by, Umar Rao

Software required :
CapacitiveSensor library by Paul Badger
http://arduino.cc/playground/Main/CapacitiveSensor
*/

#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);
}


No comments:

Post a Comment