Other Arduino Codes and Videos by Robojax

TTP224 4 Channel Capacitive Touch Arduino Basic Code

دروس آردوینو به فارسی

TTP224 4 Channel Capacitive Touch Arduino Basic Code

This video shows you how to use TTP224 4 Channel Capacitive Touch and code
  1. download Firtzing File
  2. download TTP224 Capacitive Touch Manual
  3. 
     /*
     * This is the Arduino code for TTP 224 4 Channel Capacitive Touch switch 
     * the output pen 10, 11, 12 and 13 will be ON when key 1 to 4 are pressed respectively
     * pressing button 1, Turns pin 10 ON
     * pressing button 2, Turns pin 11 ON
     * pressing button 3, Turns pin 12 ON
     * pressing button 4, Turns pin 13 ON
     * 
     * Written by Ahmad Shamshiri for Robojax Video
     * Date: Dec 02, 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, HIGH); // Turn the LED ON     
          delay(LD); 
        }else{
          digitalWrite(10, LOW);// Turn OFF the LED
        }
    
        // button 2 action
        if(digitalRead(3)){
          Serial.println("Button 2 Touched "); 
          digitalWrite(11, HIGH); // Turn the LED ON
          delay(LD); 
        }else{
          digitalWrite(11, LOW);// Turn OFF the LED
        }   
    
        // button 3 action
        if(digitalRead(4)){
          Serial.println("Button 3 Touched "); 
          digitalWrite(12, HIGH); // Turn the LED ON       
          delay(LD); 
        }else{
          digitalWrite(12, LOW);// Turn OFF the LED
        }     
    
       // button 4 action
        if(digitalRead(5)){
          Serial.println("Button 4 Touched "); 
          digitalWrite(13, HIGH); // Turn the LED ON      
          delay(LD); 
        }else{
          digitalWrite(13, LOW);// Turn OFF the LED
        }
    
    }// loop
    
        
    
    
    
       

    If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal