Touch applications are very common, from mobile phones, lights, water dispenser switches, etc., are all touch applications. Generally, in stores selling electronic parts, you can see several different capacitive touch modules, such as single button, 4 button, 8 button and 16 button, etc. I bought a 4 button module TTP224 to try it.
TTP224 is a 4-key capacitive touch module. It detects whether the position is touched through the touch detection IC (TTP224). We can install the TTP224 module on the surface of non-metallic materials such as plastic and glass, and cover the surface of the module with a thin sheet of paper (non-metal). As long as the touch position is correct, it can be hidden on the wall or desktop. Wait for the button. When the finger touches the relative position, the module will output a high potential.
I tried to use 3 buttons to control 3 LED lights. When I touch the switch, the LED lights will be on and will go out as soon as I release the hand. Button 4 is the function of the switch, press once to fully open, and then press to fully close. Let's try how to switch the LED light through capacitive touch.
TTP224 is a 4-key capacitive touch module. It detects whether the position is touched through the touch detection IC (TTP224). We can install the TTP224 module on the surface of non-metallic materials such as plastic and glass, and cover the surface of the module with a thin sheet of paper (non-metal). As long as the touch position is correct, it can be hidden on the wall or desktop. Wait for the button. When the finger touches the relative position, the module will output a high potential.
I tried to use 3 buttons to control 3 LED lights. When I touch the switch, the LED lights will be on and will go out as soon as I release the hand. Button 4 is the function of the switch, press once to fully open, and then press to fully close. Let's try how to switch the LED light through capacitive touch.
[TTP224 Capacitive Touch]
- Onboard TTP224 capacitive 4-button touch sensor IC
- 4 onboard level status indicators
- Working voltage: 2.4V-5.5V
- The module can set output mode, key output mode, maximum output time and fast/low power consumption selection
- PCB board size: 35(mm)x29(mm)
[Material]
- Arduino Uno x 1
- TP224 capacitive touch module x 1
- LED red and green 1 each
- 220K resistance x 3
- connection line xn
[Wiring diagram]
Arduino | TTP224 capacitive touch panel |
---|---|
5V (VCC) | VCC |
GND | GND |
Pin 2 | OUT 1 |
Pin 3 | OUT 2 |
Pin 4 | OUT 3 |
Pin 5 | OUT 4 |
[Code]
boolean b4=false; // LED status void setup() { Serial.begin(9600); // LED pinMode(9, OUTPUT); // LED 1 pinMode(10, OUTPUT); // LED 2 pinMode(11, OUTPUT); // LED 3 // 按鍵 pinMode(2, INPUT); // Button 1 pinMode(3, INPUT); // Button 2 pinMode(4, INPUT); // Button 3 pinMode(5, INPUT); // Button 4 } void loop() { // Button 1 if(digitalRead(2)){ Serial.println("Button 1 Touched "); digitalWrite(9, HIGH); // LED on delay(200); } else{ digitalWrite(9, LOW); // LED off } // Button 2 if(digitalRead(3)){ Serial.println("Button 2 Touched "); digitalWrite(10, HIGH); // LED on delay(200); } else{ digitalWrite(10, LOW); // LED off } // Button 3 if(digitalRead(4)){ Serial.println("Button 3 Touched "); digitalWrite(11, HIGH); // LED 亮 delay(200); } else{ digitalWrite(11, LOW); // LED 熄滅 } // Bunnton 4 if(digitalRead(5)){ Serial.println("Button 4 Touched "); b4=!b4; // change the switch state delay(300); } if (b4) { // LED is all on digitalWrite(9, HIGH); digitalWrite(10, HIGH); digitalWrite(11, HIGH); } else{ // LED off digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); } }
[Result]
Tags:
Arduino