TTP223 Capacitive Touch Sensor Features
The TTP223 sensor can be used in a variety of applications such as smartphones and tablets. The sensor can recognize objects even from behind glass and thin surfaces. The operating voltage is 2 to 5.5V. The maximum response time is 220 milliseconds. This module has two non-soldered adjustment pins: A and B. The working modes are as follows:
- A and B both open: The default value of the output pin is LOW. When the sensor is subjected to touch, the output is HIGH, and when no touching detected, it becomes LOW again.
- A open and B closed: the default value of the output pin is LOW. When the sensor is subjected to touch, the output is HIGH and remains HIGH until the next touch.
- B open and A closed: the default value of the output pin is HIGH. When the sensor is subjected to touched, the output is LOW and when no touching detected, it becomes HIGH again.
- B closed and A closed: The default value of the output pin is HIGH. When the sensor is subjected to touch, the output is LOW and remains LOW until the next touch.
You can download the datasheet of this sensor here.
TTP223 Capacitive Touch Sensor Datasheet
TTP223 Capacitive Touch Sensor Pinout
This module has 3 pins:
- VCC: Module power supply – 2 – 5.5V
- GND: Ground
- OUT: Digital output
You can see the pinout of this module here.
Required Materials
Hardware Components
Software Apps
Interfacing TTP223 Capacitive Touch Sensor with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to TTP223 sensor. Connect wires accordingly.
Step 2: Code
Upload the following code to Arduino.
/*
TTP223B-Capacitive-Touch-Switch-Module
made on 08 Nov 2020
by Amir Mohammad Shojaee @ Electropeak
Home
*/
const int SENSOR_PIN = 2;
void setup() {
Serial.begin(9600);
// initialize the Arduino's pin as aninput
pinMode(SENSOR_PIN, INPUT);
}
void loop() {
if(digitalRead(SENSOR_PIN) == HIGH){
Serial.println("Sensor is touched");
while(digitalRead(SENSOR_PIN) == HIGH){}
}
}
When the digital output is HIGH, the phrase “Sensor is Touched” is displayed on the Serial Monitor.
The output is as follows. As you can see, the sensor has been touched 6 times.