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.
you'll need these things...
- arduino nano (cause its breadboard friendly)
- a copper plate or any metal plate for TOUCHPAD
Step 1: SCHEMATIC
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.
Step 2: CODE
download the library before using this code.
Here's the code
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 p = LOW;
long time = 0;
long debounce = 200;
r = digitalRead(4);
if (r == HIGH && p == LOW && millis() - time > debounce)
if (state == HIGH) state = LOW;
else state = HIGH;
time = millis();
p = r;
Step 3: 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..