Arduino Capacitive Touch Setup

Introduction: Arduino Capacitive Touch Setup

About: Hello world;

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

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.

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;

}

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..

GOOD LUCK

Be the First to Share

    Recommendations

    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Lamps Challenge

      Lamps Challenge
    • Puzzles Challenge

      Puzzles Challenge

    Comments