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
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]
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);
}
[/c]
Links
1pc TTP224 4-way Capacitive Touch Switch Module Digital Touch Sensor