Site icon DIY Usthad

How to use a TTP223 based touch switch

ttp223

Today we are going to learn the following about touch switch based on TTP223.

TTP223 Features

Hardware Required

ComponentsDIY UsthadAmazon.comBanggoodAliExpressUtsource
Arduino Nano
TTP223 Touch Switch

Touch switch configurations

There are four different configurations for this touch switch, which is explained below in details.

Config 1: 

Config 2:

Config 3:

Config 4:

Adjusting touch sensitivity 

Sensitivity can adjust by adding a capacitance, the value of capacitor ranges from 0 to 50 pf, where 0pf gives the full sensitivity and 50pf will gives the lowest sensitivity. For example, if you needed the touch switch to work through glass or acrylic you will need to adjust the sensitivity based on the thickness of the material.

Connecting with LED

Interfacing with Arduino

ArduinoTouch Sw
GNDGND
5VVCC
D3I/O

Watch the video to understand it better 

Code

//www.diyusthad.com

#define touchSw 4

void setup() {

  pinMode(touchSw,INPUT);

  Serial.begin(9600); 

}
 

void loop() {

  boolean touchState;

  touchState = digitalRead(touchSw);

  Serial.println(touchState);

 
  if(touchState == HIGH)

  {

    //write statements to execute when the sw is high

  }

  else

  {

    //write statements to execute when the sw is low

  }

}

To buy electronic components order from UTSOURCE

Exit mobile version