Arduino Capacitive Touch Setup

by Arnov Sharma in Circuits > Arduino

2147 Views, 3 Favorites, 0 Comments

Arduino Capacitive Touch Setup

Capacitive Touch Arduino WITHOUT using capacitive touch sensor TTP223
Image1.jpg

Hey everyone, in this tutorial I'll be showing you guys how you can use the capacitive sensor library to make an Arduino nano-based TOUCH SENSOR to toggle a LED WITHOUT USING TTP223 touchpad sensor module.

Supplies

you'll need these things...

  • arduino nano (cause its breadboard friendly)
  • jumperwires
  • a copper plate or any metal plate for TOUCHPAD
  • LED

SCHEMATIC

4.PNG
Capture.PNG

here's the SCH, wire everything just like this and you'll be good.

connect the copper plate to pin 4, this will be our touchpad.

I've added mosfet to this setup so we can trigger loads like a motor, relay etc but you can remove it and connect an LED instead.

CODE

download the library before using this code.

https://github.com/arduino-libraries/CapacitiveSen...

Here's the code

#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 = LOW;

int r;

int p = LOW;

long time = 0;

long debounce = 200;

void setup()

{

pinMode(4, INPUT);

pinMode(3, 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(3, state);

p = r;

}

THIS WILL NOT WORK UNLESS

this project has a flaw, which is the ground problem.

this will not work unless your laptop or computer is connected to the power plug which has an earth connection.

just plug in your laptop charger and test this setup, it will work..

GOOD LUCK