Capacitive touch sensors are commonly used in electronic projects due to their high sensitivity, compact size, and energy efficiency. Among these, the TTP223B capacitive touch sensor has gained popularity for its simplicity, versatility, and low power consumption. This tutorial will provide a detailed explanation of how to interface the TTP223B touch sensor with an Arduino Uno.
What is TTP223B Capacitive Touch Sensor?The TTP223B is a one-channel capacitive touch sensor module based on the TTP223-BA6 integrated circuit. It is designed to detect changes in capacitance caused by touch, making it a perfect replacement for traditional push buttons. It operates between 2.0V and 5.5V, making it compatible with most Arduino boards. The sensor outputs a digital HIGH or LOW signal depending on whether a touch is detected. An onboard LED lights up when the sensor is triggered, providing a visual indicator.
Features of TTP223B Touch Sensor- Low Power Consumption: The module consumes very little power, typically 1.5 µA at 3V.
- Wide Operating Voltage: Works with voltages ranging from 2.0V to 5.5V, making it compatible with both 3.3V and 5V systems.
- Adjustable Sensitivity: The sensor's sensitivity can be fine-tuned using an external capacitor (0 to 50pF).
- Modes of Operation: Offers direct mode and toggle mode with options for active HIGH or active LOW output.
- Auto Calibration: Continuously adjusts its sensitivity to maintain consistent performance.
- Compact Design: The sensor includes mounting holes for easy installation in electronic projects.
- Human Touch Stability: Provides stable touch detection.
The TTP223B operates on the principle of capacitive sensing. Every object has inherent capacitance, including human fingers. When a conductive object such as a finger approaches or touches the sensor’s electrode, the capacitance of the system changes.
The TTP223-BA6 IC processes this change using an oscillator circuit, which generates a digital output signal. The control logic circuit evaluates this signal and identifies touch events. The output driver circuit responds by toggling the state of the output pin, indicating the presence or absence of touch. This behavior is managed entirely by the TTP223-BA6 IC, ensuring seamless and reliable touch detection.
TTP223-BA6 Pinout Description- Signal (Q): The digital output pin. It indicates whether a touch is detected (HIGH or LOW).
- Sensor Input (I): Senses the system's capacitance changes and acts as the input pin.
- AHLB (Active HIGH/LOW Pin): Determines the active state of the output signal. When LOW, the output is active HIGH. When HIGH, the output is active LOW.
- TOG (Toggle Pin): Controls the output mode. LOW enables direct mode, while HIGH enables toggle mode.
- VDD (Power Supply): Connected to the supply voltage (2.0V to 5.5V).
- VSS (GND): Connected to the ground of the power suppl
In toggle mode, the sensor switches its output state with each touch event. For example:
- The initial state is LOW.
- The first touch toggles the state to HIGH.
- The second touch switches it back to LOW.
This behavior makes toggle mode suitable for applications such as controlling lights or turning devices on and off.
TTP223B Touch Sensor PinoutThe TTP223B capacitive touch sensor module has three primary pins that are essential for its operation.
- VDD (Power Supply Pin)The VDD pin is used to power the TTP223B module. It typically requires a voltage supply between 2.0V and 5.5V DC. This flexibility in input voltage makes the sensor compatible with a wide range of microcontrollers and power sources. When connected to a suitable power source, the internal circuits of the TTP223B sensor become active and ready to detect touch events.
- Signal (Digital Output Pin)The Signal pin is the output pin of the touch sensor. It provides a digital signal indicating the detection of a touch event. When the sensor detects a touch, the Signal pin goes HIGH (typically equivalent to the supply voltage level). If no touch is detected, the pin remains LOW (typically at ground level). This binary output is ideal for interfacing with Arduino digital input pins, enabling touch detection to be easily read and utilized in various electronic projects.
- GND (Ground Pin)The GND pin serves as the ground connection for the sensor module. It must be connected to the ground terminal of the power source or the Arduino to complete the circuit. Proper grounding is critical to ensure stable operation and accurate touch detection by the sensor.
Let us interface TTP223B touch sensor with Arduino UNO.
The TTP223B touch sensor is powered by the Arduino’s 5V and GND pins. This ensures the sensor operates at a stable voltage level, providing reliable touch detection.The Signal pin of the touch sensor is connected to digital input pin 2 on the Arduino. This connection allows the Arduino to read the digital output from the touch sensor, which will be HIGH when a touch is detected and LOW otherwise.A Red LED is connected to digital pin 4 of the Arduino through a 100-ohm resistor. The resistor limits the current flowing through the LED to prevent damage and ensure it lights up appropriately.
When a touch is detected on the TTP223B sensor, the Signal pin goes HIGH. The Arduino reads this HIGH signal and turns on the LED connected to pin 4.The Arduino also displays the message “Touch Detected” on the Serial Monitor window of the Arduino IDE, providing visual feedback in the software interface.
Code/*
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);
}
}
OutputFor a more in-depth guide on, check out our detailed project tutorials: Interfacing TTP223B Touch Sensor with Arduino
Comments
Please log in or sign up to comment.