TTP223B Touch Sensor With Arduino

by Rachana Jain in Circuits > Arduino

244 Views, 1 Favorites, 0 Comments

TTP223B Touch Sensor With Arduino

Interfacing TTP223 Touch Sensor with Arduino.jpg

Capacitive touch sensors have gained popularity in modern electronics due to their compact size, low power consumption, and ability to replace mechanical buttons. One such commonly used module is the TTP223B Capacitive Touch Sensor, which offers a simple way to integrate touch-based input into Arduino projects. In this article, we will walk through how to interface the TTP223B touch sensor with an Arduino Uno. We’ll cover everything from its working principle and pinout to wiring and Arduino code.

Supplies

Arduino Uno

TTP223B Touch Sensor Module

1 × Red LED

1 × 100Ω resistor

Breadboard and jumper wires

What Is the TTP223B Capacitive Touch Sensor?

The TTP223B is a 1-channel capacitive touch sensor module built around the TTP223-BA6 touch-sensing IC. It is designed to detect human touch through capacitive sensing, offering a digital output that changes state when a touch is detected.

This module is commonly used in place of traditional buttons in various touch-sensitive applications such as smart lamps, DIY electronics, and embedded systems.

Key Features of TTP223B


  1. Operates on 2.0V to 5.5V DC
  2. Low power consumption (typically 1.5µA at 3V)
  3. Stable touch detection for human body input
  4. Can operate in Direct or Toggle mode
  5. Output type can be set to Active HIGH or Active LOW
  6. Auto calibration functionality
  7. Can replace traditional mechanical switches
  8. Adjustable sensitivity using an external capacitor (0~50pF)
  9. Mounting holes for easy installation

Working Principle of TTP223B

The TTP223B works using the principle of capacitive sensing. Every object has a certain capacitance, and the human body is no exception. When a conductive object like a finger comes close to the sensor pad, it alters the capacitance.

Here's a step-by-step breakdown of how it works:

  1. Capacitive electrodes on the module detect changes when a finger is near or in contact with the sensor.
  2. This change in capacitance is detected by the internal oscillator circuit.
  3. The oscillator signals are processed by the IC’s control logic circuit.
  4. When a valid touch is detected, the output driver toggles or sets the digital output pin (Q pin) accordingly.

All of this is handled by the TTP223-BA6 IC present on the module.

TTP223 IC Pinout

Pin Diagram of TTP223-BA6 IC.JPG

VDD: Power supply pin (2.0V to 5.5V DC)

VSS (GND): Ground pin

I (Sensor Input): Touch sensing input connected internally to the touch pad

Q (Signal Output): Digital output pin: HIGH when touched, LOW when untouched (in default mode)

TOG: Toggles between direct or toggle output mode

AHLB: Sets output type as Active HIGH or LOW

TTP223B Touch Sensor Module Pinout

Pinout of TTP223B touch Sensor.JPG

VCC: Power supply input (connect to 2V–5.5V, usually 5V from Arduino)

GND: Ground connection

SIG: Digital output (connects to Arduino digital pin)

Interfacing TTP223B With Arduino

Interfacing TTP223B Touch Sensor with Arduino.JPG

In the circuit diagram, a TTP223B capacitive touch sensor is interfaced with an Arduino UNO board.

The sensor is powered by the 5V and GND pins of the Arduino, supplying the necessary operating voltage. The Signal pin of the TTP223B is connected to digital pin 2 of the Arduino, allowing it to detect touch events.

Additionally, a red LED is connected to digital pin 4 of the Arduino through a 100-ohm resistor. When the sensor detects a touch, the Arduino receives a HIGH signal on pin 2, turns ON the LED connected to pin 4, and prints the message "Touch Detected" on the Serial Monitor of the Arduino IDE.

Code

Upload the following code to your Arduino:

/*
Interfacing TTP223B Touch Sensor with Arduino
by www.PlaywithCircuit.com
*/
// Define pin numbers
const int touchPin = 2; // Define the pin number for touch sensor
const int ledPin = 4; // Define the pin number for LED
void setup() {
// Initialize serial communication at 9600 baud
Serial.begin(9600);
// Set pin modes
pinMode(touchPin, INPUT); // Set touchPin as input
pinMode(ledPin, OUTPUT); // Set ledPin as output
}
void loop() {
// Read the state of the touch sensor
int touchState = digitalRead(touchPin);
// Check if touch is detected
if (touchState == HIGH) {
// Turn on LED
digitalWrite(ledPin, HIGH);
// Print touch detected message
Serial.println("Touch detected!");
// Staty in the below loop as long as touch is detected.
while (digitalRead(touchPin) == HIGH);
} else {
// Turn off LED
digitalWrite(ledPin, LOW);
}
}

Output

How to use Touch Sensor Switch with Arduino (TTP223B Capacitive Touch Sensor)

The TTP223B capacitive touch sensor is a simple yet powerful module for adding touch functionality to your Arduino projects. With minimal wiring and straightforward programming, it is ideal for hobbyists and prototyping interactive projects like touch-controlled lamps, switches, or appliances.

If you want to learn more details checkout: Interfacing TTP223B Touch Sensor with Arduino