Interface TTP223 Capacitive Touch Sensor with Arduino

What are touch sensors?

Touch sensors are devices that detect physical touch or pressure applied to a surface. They are widely used in consumer electronics, such as smartphones and tablet computers, as well as in industrial applications, such as machine controls and security systems.

There are several types of touch sensors, including:

-Capacitive touch sensors: Detect changes in capacitance caused by the presence of a finger or other conductive object on the surface.
-Resistive touch sensors: Detect changes in resistance caused by the pressure applied to the surface.
-Infrared touch sensors: Detect the interruption of an infrared beam by a finger or other object touching the surface.
-Surface acoustic wave (SAW) touch sensors: Detect changes in ultrasonic waves that propagate along the surface.

Touch sensors can be used to provide inputs to a system, such as selecting an option on a display, adjusting the volume of a device, or triggering an action in a control system. They are widely used in applications that require user interaction and can provide a more intuitive and user-friendly interface compared to traditional buttons or switches.

TTP223 Capacitive Touch Sensor

The TTP223 is a 1-Channel Capacitive type Touch Sensor Module that is based on a touch-sensing IC TTP223. The sensor can even recognize touch from behind the glass and thin surfaces. It can be used in a variety of applications such as smartphones, tablets, computers, smart gadgets and LCD/LED displays.

An LED is also present on the module that gives a visual indication of when the sensor is triggered. 

This module has two non-soldered adjustment pins: A and B. The working modes are as follows:

 

TTP233 touch sensor different mode of operations

 

  1. If A and B both are open then the default value of the output pin is set to LOW. When you will touch the sensor, it will output a logic HIGH, and when no touch is detected, it will output a logic low.
  2. If A is open and B is closed the default value of the output pin is set to LOW. When you will touch the sensor, it will output logic HIGH and remains HIGH until the next touch.
  3. If B is open and A is closed then the default value of the output pin is set to HIGH. When you will touch the sensor, it will output logic LOW and when no touch is detected, it will output logic HIGH.
  4. If A and B both are closed then the default value of the output pin is set to HIGH. When you will touch the sensor, it will output logic LOW and remains LOW until the next touch.

When you buy a new sensor both A and B are open. So, the sensor will work based on the mode 1.

Touch sensor specification

  • Operating voltage: 2-2.5V
  • Operating current: 1.5uA
  • Response time: ~60ms in fast mode and ~220ms in low power mode(3V)

Pin diagram of touch sensor

TTP233 touch sensor pin diagram

Circuit diagram of the TTP233 touch sensor with Arduino

TTP233 touch sensor circuit diagram with arduino

Pin connections of the TTP233 touch sensor with the Arduino 

  • Connect GND pin of the TTP233 touch sensor to the GND pin of the Arduino UNO board.
  • Connect VCC pin of the TTP233 touch sensor to the 5V pin of the Arduino UNO board.
  • Connect OUT pin of the TTP233 touch sensor to the D3 pin of the Arduino UNO board.

Arduino Code for interfacing Touch sensor with Arduino

int sensor = 3; 
         
void setup(){
  Serial.begin(9600);
  pinMode(sensor, INPUT);
}

void loop(){

  int sensorData=digitalRead(sensor);
  
  if(sensorData == HIGH)
   Serial.println("Sensor is touched");
  else
   Serial.println("Sensor is not touched");
}

Arduino code working

int sensor = 3; 
         
void setup(){
  Serial.begin(9600);
  pinMode(sensor, INPUT);
}

First, create a variable to store the pin number of the Arduino UNO board where you have connected the OUT pin of the TTP233 sensor.
Inside the void setup() block, initiate serial communication using the Serial.begin(9600) command and set the baud rate to 9600.
Then, set the sensor pin as INPUT using the pinMode() function. Arduino will use this pin to get data from the sensor.

void loop(){

  int sensorData=digitalRead(sensor);

Inside the void loop block, create a variable to store the data that is received by the Arduino from the sensor pin(D3).

 if(sensorData == HIGH)
   Serial.println("Sensor is touched");
  else
   Serial.println("Sensor is not touched");
}

Use the if-else statements to check whether the touch is detected or not. If touch is detected by the sensor then print “Sensor is touched” on the serial monitor and if not then print “Sensor is not touched”.

Leave a Reply