In this example I connect a TTP224 4-CHANNEL CAPACITIVE TOUCH module that I bought recently to an Arduino. This capacitive module offers 4 touch pads, here is a picture of this
The TTP224/TTP224N TonTouchTM IC is capacitive sensing design specifically for touch pad controls. The device built in regulator for touch sensor. Stable sensing method can cover diversity conditions. Human interfaces control panel links through non-conductive dielectric material. The main application is focused at replacing of the mechanical switch or button. The ASSP can independently handle the 4 touch pads with 4 direct output pins.
Schematic
We connect the 4 outputs to Arduino pins 4 to 7, this is a basic schematic
Code
Copy the following into your Arduino IDE and uplaod the sketch, now open the serial monitor and press one of the number buttons. The serial monitor displays the button pressed.
[c]
[codesyntax lang=”cpp”]
int i; void setup() { //set pins 4 - 7 as inputs for(i=4; i<=7; i++) { pinMode(i, INPUT); } Serial.begin(9600); } void loop() { for(i=4; i<=7; i++) { if(digitalRead(i) == HIGH) { //I'm using pins 4 - 7 so subtract 3 to match //numbering on module Serial.println(i-3); } } delay(100); }
[/codesyntax]
Links
1pc TTP224 4-way Capacitive Touch Switch Module Digital Touch Sensor