Capacitive Touch ON/OFF Switch with Arduino Nano

Capacitive Touch Sensor with Arduino Nano

Description: A copper coin is used as a conductive metal capactive touch sensor to turn ON/OFF an LED light with an Arduino Nano. Copper wire was taped with electrical tape to the back of a copper coin to ensure a conductive connection.

Installing the Library: In the Arduino IDE under the Tools menu navigate to Manage Libraries and search for CapacitiveSensor. Proceed to install the CapacitiveSensor Library by Paul Badger as shown in the image below.

Installing CapacitiveSensor Library

Supplies:

1 – Breadboard 830 Points
1 – Arduino Nano   >> Link <<
1 – Copper Coin
1 – LED
1 – 220 Ohm Resistor

Arduino Code: 

#include <CapacitiveSensor.h>
CapacitiveSensor Sensor = CapacitiveSensor(3, 6);
long val;
int pos;
#define led 13

void setup() {
  
  Serial.begin(9600);
  pinMode(led, OUTPUT);
 
}

void loop() {

  val = Sensor.capacitiveSensor(30);
  Serial.println(val);
  
  if (val >= 100 && pos == 0) {
  digitalWrite(led, HIGH);
  pos = 1;
  delay(500);
  
}

  else if (val >= 100 && pos == 1) {
  digitalWrite(led, LOW);
  pos = 0;
  delay(500);
  
}

 delay(10);
 
}

Leave a Comment

3 + = 10