TTP224 Touch Sensor
This module is a capacitive touch switch module based on the touch detection IC (TTP223B). In its normal state, the module outputs a low level and operates in low-power mode. When the corresponding position is touched with a finger, the module will output a high level and switch to a fast mode. If no touch is detected for 12 seconds, the module will switch back to low-power mode. The module can be installed on non-metallic materials such as plastic or glass surfaces. It is also possible to cover the surface of the module with a thin sheet of paper (non-metallic) until the touch position is correct, allowing it to be used as a hidden button in places like walls or tabletops. This module helps you avoid the hassle of conventional pressure-type buttons.
Module Source
Purchase Link:
https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-24706531953.10.37476a4b0lAfi7&id=522552731734
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1lBksfqx_dT4uIyABkHVm3Q
Password: hj2n
Specifications
Operating Voltage: 2.4V to 5.5V
Operating Current: 2.5uA to 9uA
Module Size: 35mm x 29mm
Fastest Response Time: 100ms
Control Method: GOIO (General Input/Output)
Pin Count: 6 pins (2.54mm pitch header)
Hardware Connection
Generally, the TTP224 module has four touch keys, with each key corresponding to an output pin. Additionally, there are two power supply pins, VCC and GND.
- Connect the VCC of TTP224 to the 5V of the development board.
- Connect the GND of TTP224 to the GND of the development board.
- Connect the output pins of TTP224 (usually labeled OUT1, OUT2, OUT3, OUT4) to the digital input pins 2, 3, 4, and 5 of the development board.
Usage Method
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 8, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
// 定义连接到TTP224触摸传感器输出的Arduino引脚
const int touchPin1 = 2; //OUT1
const int touchPin2 = 3;//OUT2
const int touchPin3 = 4;//OUT3
const int touchPin4 = 5;//OUT4
void setup() {
// 初始化串行通信
Serial.begin(9600);
// 将触摸传感器连接的引脚配置为输入
pinMode(touchPin1, INPUT);
pinMode(touchPin2, INPUT);
pinMode(touchPin3, INPUT);
pinMode(touchPin4, INPUT);
}
void loop() {
// 读取各个触摸键的状态
int state1 = digitalRead(touchPin1);
int state2 = digitalRead(touchPin2);
int state3 = digitalRead(touchPin3);
int state4 = digitalRead(touchPin4);
// 如果任一触摸键被按下,打印其状态
if (state1 == HIGH || state2 == HIGH || state3 == HIGH || state4 == HIGH) {
Serial.print("Touch states: ");
Serial.print(state1);
Serial.print(" ");
Serial.print(state2);
Serial.print(" ");
Serial.print(state3);
Serial.print(" ");
Serial.println(state4);
}
delay(100); // 稍作延迟,避免过于频繁的读取
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Usage Testing
Touch each of the 4 areas separately, and the touched area is displayed as 1 in the serial port debugging tool.