Amal Mathew
Published © GPL3+

Touch Controlled Light Using Arduino

In this project I made a touch sensor using a coin that works based on Arduino Capacitive Sensing Library.

BeginnerFull instructions provided12 minutes28,843
Touch Controlled Light Using Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×4
1 Mega Ohm Resistor
×1
Aluminium foil or Coin
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit diagram

Code

Arduino code

Arduino
Make Sure that you have installed Capacitive Sensing Library.
#include <CapacitiveSensor.h>

CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4); // 1M resistor between pins 2 & 4, pin 4 is sensor pin, add a wire and or foil

int in = 2; 
int out = 4;  
int state = HIGH;  
int r;           
int p = LOW;    
long time = 0;       
long debounce = 200;
void setup()
{
  pinMode(4, INPUT);
  pinMode(8, OUTPUT);
}
void loop()                    
{
 
  r = digitalRead(4);
  if (r == HIGH && p == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
    else 
      state = HIGH;
    time = millis();    
  }
  digitalWrite(8, state);
  p = r;
}

Credits

Amal Mathew

Amal Mathew

24 projects • 79 followers
Maker | Not much to boast about – just a human, open-source believer. Simple as that.

Comments