Introduction to TTP223 Capacitive touch module for Arduino Robojax.com

The source code for TTP223 Touch Module for Arduino



 // April 01, 2017
 // Written for Robojax.com video 
 // Introduction to TTP223 Touch module.
 // When the touch pad is touched the ligh on the relay will on and the COM and PO pin will be connected
int touchPin = 2;// connect output from TTP223 to this
int val = 0; 
int relayPin = 8;// Connected to relay

void setup() {
 Serial.begin(9600);
 pinMode(touchPin, INPUT); 
  pinMode(relayPin, OUTPUT);

}

void loop() {
  digitalWrite(relayPin, HIGH);
  val = digitalRead(touchPin); 
  if(val ==1){
  Serial.println("Touched");
  digitalWrite(relayPin, LOW);
  }
  delay(100);
  Serial.println();
}