TOUCH CONTROLLED LIGHT USING ARDUINO
In this project I made a touch controlled light with coin that works based on Arduino Capacitive Sensing Library.
OVERVIEW
In this project I made a touch sensor using a coin that works based on arduino Capacitive Sensing Library. I used this sensor to turn on and turn off LED by touching on it. Capacitive sensors can detect anything that is conductive or that has a significantly different permitivity than air, like a human body or hand.
DETAILS
It’s a simple RC circuit (Resistor-Capacitor). By measuring the time it takes to go form one state to the other, you get an approximation of distance (we know the general capacitance of the human body, the high value resistor, and the general capacitance of the sensor material) . The high value resistor is to provide a significantly low drain time.
In this Project you can use sensor material as any metallic objects such as coin or aluminium foil etc.
Insert the high value resistor (1 M Ω) in between 2 and 4th pin of Arduino. As per the program pin 4 is receive pin , so connect the coin(coin act as capacitive sensor) to the receive pin. .Connect Led to in-between GND and 8th pin
Whenever you touches the sensor it changes the previous state, that is turning on or off the LED. Larger resistor tend to make the sensor more sensitive and acts like Proximity Sensor.
COMPONENTS NEEDED:
FRITZING DIAGRAM
PIC 3
CODE
// import the library (must be located in the // Arduino/libraries directory) #include <CapacitiveSensor.h> // create an instance of the library // pin 4 sends electrical energy // pin 2 senses senses a change CapacitiveSensor capSensor = CapacitiveSensor(4, 2); // threshold for turning the lamp on int threshold = 1000; // pin the LED is connected to const int ledPin = 8; void setup() { // open a serial connection Serial.begin(9600); // set the LED pin as an output pinMode(ledPin, OUTPUT); } void loop() { // store the value reported by the sensor in a variable long sensorValue = capSensor.capacitiveSensor(30); // print out the sensor value Serial.println(sensorValue); // if the value is greater than the threshold if (sensorValue > threshold) { // turn the LED on digitalWrite(ledPin, HIGH); } // if it's lower than the threshold else { // turn the LED off digitalWrite(ledPin, LOW); delay(10); } }
CONCLUSION
We hope you enjoyed the tutorial and this little lesson will purport you into great levels. Enjoy yourself in electronics. For more tutorials and questions, please leave your comments in the comment area. See other components on the site www.inventelectronics.com. Inspiring ingenuity.