TTP224 4 channel Touch Sensor Turn AC/DC load with Relay
TTP224 4 Channel Capacitive Touch Arduino with Relay Code
This video shows you how to use TTP224 4 Channel Capacitive Touch with relay and code- download Firtzing File
- download TTP224 Capacitive Touch Manual
/*
* This is the Arduino code for TTP 224 4 Channel Capacitive Touch switch
* the output pen 10, 11, 12 and 13 will be LOW when key 1 to 4 are pressed respectively
* and the connected relay will go ON
* pressing button 1, Turns pin 10 LOW
* pressing button 2, Turns pin 11 LOW
* pressing button 3, Turns pin 12 LOW
* pressing button 4, Turns pin 13 LOW
*
* Written by Ahmad Nejrabi for Roboja Video
* Date: Dec 03, 2017, in Ajax, Ontario, Canada
* Permission granted to share this code given that this
* note is kept with the code.
* Disclaimer: this code is "AS IS" and for educational purpose only.
*
*/
int LD = 200; // Loop Delay. Do not change.
void setup() {
Serial.begin(9600);
// out pins
pinMode(10, OUTPUT);// LED for button 1
pinMode(11, OUTPUT);// LED for button 2
pinMode(12, OUTPUT);// LED for button 3
pinMode(13, OUTPUT);// LED for button 4
// input pins
pinMode(2, INPUT);// Button 1 input pin 2
pinMode(3, INPUT);// Button 2 input pin 3
pinMode(4, INPUT);// Button 3 input pin 4
pinMode(5, INPUT);// Button 4 input pin 5
Serial.println("Robojax Test");
}
void loop() {
// button 1 action
if(digitalRead(2)){
Serial.println("Button 1 Touched ");
digitalWrite(10, LOW); // Turn the LED ON
delay(LD);
}else{
digitalWrite(10, HIGH);// Turn OFF the LED
}
// button 2 action
if(digitalRead(3)){
Serial.println("Button 2 Touched ");
digitalWrite(11, LOW); // Turn the LED ON
delay(LD);
}else{
digitalWrite(11, HIGH);// Turn OFF the LED
}
// button 3 action
if(digitalRead(4)){
Serial.println("Button 3 Touched ");
digitalWrite(12, LOW); // Turn the LED ON
delay(LD);
}else{
digitalWrite(12, HIGH);// Turn OFF the LED
}
// button 4 action
if(digitalRead(5)){
Serial.println("Button 4 Touched ");
digitalWrite(13, LOW); // Turn the LED ON
delay(LD);
}else{
digitalWrite(13, HIGH);// Turn OFF the LED
}
}// loop