In our previous tutorial, we have seen a Sound detecting sensor interfacing with 8051. In this tutorial, we are going to discuss Touch Sensor Interfacing with 8051 (TTP223B).
Prerequisites
Before starting this tutorial we should know the below topics. If you know already, please go further.
Components Required
- 8051 Development Board
- Touch Sensor – TTP223B
- LCD Module (To print the Sensor output)
Introduction
The TTP223B is a Digital touchpad detector IC that offers 1 touch key. The touching detection IC is designed for replacing traditional direct button keys with diverse pad sizes. This device uses your body as part of the circuit.
When you touch the sensor pad, the capacitance of the circuit is changed and is detected. That detected change in capacitance results in the output changing states. In the normal state, the module output low, low power consumption; When a finger touches the corresponding position, the module output high, if not touched for 12 seconds, switch to low-power mode.
Specification
- Operating voltage 2.0V~5.5V
- ƒOperating current @VDD=3V, no-load, SLRFTB=1, At low power mode typical 1.5uA, maximum 3.0uA and At fast mode typical 3.5uA, maximum 7.0uA
- Operating current @VDD=3V, no-load, SLRFTB=0, At low power mode typical 2.0uA, maximum 4.0uA and At fast mode typical 6.5uA, maximum 13.0uA
- The response time max about 60mS at fast mode, 220mS at low power mode @VDD=3V
- Provides Fast mode and Low Power mode selection by pad option(LPMB pin)
- Operating Temperature:-20 ~ +70 ℃
Touch Sensor Pin Outs
Like a lot of the sensors out there, this is three pin sensor. You provide power, ground, and monitor the output.
- SIG – Output (If it detects touch, this will be HIGH otherwise LOW)
- VCC – 2v to 5.5v
- GND – Ground
Touch Sensor Interfacing with 8051
Connection
Touch Sensor
- Vcc – 5v
- GND – Ground
- Sig – P1.0
LCD
- RS – P2.0
- RW – P2.1
- EN – P2.2
- Data Lines – P3.0 – P3.7
Source Code
If this sensor detects any touch, LCD will display “Touch Detected”.
#include<reg51.h> #define lcd P3 sbit TOUCH=P1^0; sbit rs=P2^0; //register select sbit rw=P2^1; //RW sbit en=P2^2; //enable void lcd_init(); void cmd(unsigned char); void dat(unsigned char); void delay(); void lcd_string(char *s); void main() { lcd_init(); lcd_string(" EmbeTronicX "); while(1) { if(TOUCH) { cmd(0xc0); lcd_string("Touch Detected"); delay(); } else { cmd(0xc0); lcd_string(" "); } } } void lcd_init() { cmd(0x38); cmd(0x0e); cmd(0x06); cmd(0x01); cmd(0x80); } void cmd(unsigned char a) { lcd=a; rs=0; rw=0; en=1; delay(); en=0; } void dat(unsigned char b) { lcd=b; rs=1; rw=0; en=1; delay(); en=0; } void lcd_string(char *s) { while(*s) { dat(*s++); } } void delay() { unsigned int i; for(i=0;i<20000;i++); }
References
- Catalex TTP223B Arduino Capacitive Touch Sensor Tutorial
In our next tutorial, we will see how to interface the flame detecting sensor interfacing with 8051.
You can also read the below tutorials.

Embedded Software | Firmware | Linux Devic Deriver | RTOS
Hi, I’m SLR. I am a tech blogger and an Embedded Engineer. I am always eager to learn and explore tech-related concepts. And also, I wanted to share my knowledge with everyone in a more straightforward way with easy practical examples. I strongly believe that learning by doing is more powerful than just learning by reading. I love to do experiments. If you want to help or support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning!