Home ArduinoArduino Code Arduino capacitive touch example

Arduino capacitive touch example

by iainhendry71

In the following example we connect a capacitive touch switch to an Arduino and when a touch is detected we will switch on an LED. I used the following capacitive touch switch

Capacitive Touch

Capacitive Touch

It has 3 pins, VCC and GND for power and a SIG connection which you connect to your Arduino.


#define TOUCH_SENSOR 3 //the touch sensor is connected to D3 of the Arduino

int led = 9; // pin for the LED

void setup()
pinMode(led, OUTPUT);

void loop()
int sensorValue = digitalRead(TOUCH_SENSOR);
Serial.println("Touch detected");
digitalWrite(led, HIGH); // turn LED on
while(digitalRead(TOUCH_SENSOR) == HIGH);
Serial.println("No Touch detected");
digitalWrite(led, LOW); // turn LED off


TTP223B Digital Touch Sensor Capacitive Touch Switch Module DIY For Arduino

You may also like