Using a Digital Capacitive Touch Sensor with evive

touch sensor GIF
Description
Learn how to connect and use a Digital Capacitive Touch Sensor (TTP223B) with evive. We will discuss the pin description and circuit diagram for connecting it to evive, and how to write an Arduino code to read the value of the signal pin.

Introduction

The Digital capacitive touch sensor module (TTP223B) outputs “LOW” until touched on the circular marked region, at which point it outputs “HIGH” and quickly responds. After 12 seconds of no touch, it switches back to the low-power state. It can be mounted on non-metallic surfaces such as glass, plastic, and acrylic, allowing for hidden keys in walls and desks.
The TTP223 is an integrated circuit that detects when a finger is close to a surface, stimulating a button press like a traditional direct button key. It is designed to replace direct button keys and is ideal for applications that require low to no human force sensing.

Pin description

The Digital Capacitive touch switch  sensor  module has 3 pins ( 2- power supply pins and 1- digital signal pin )

  • VCC
  • GND
  • SIG  (Digital signal pin )

Circuit Diagram

  • Connect the “VCC”  of the touch switch module to the “VCC” of the evive board
  • Connect the “GND”  of the touch switch module to the “GND ” of the evive board
  • Connect the “SIG” pin  of the touch switch module to digital pin number 8 of the evive board

Arduino Code

/*
 * evivie
 * this code demonstrate iterfacing of digital capacitive touch sensor module
 * 
 * created on 12th june 2018
 * by punit chotaliya
 */


#include<evive.h>

const int signalpin = 8;    // declaring variable for signal pin of touch sensor module 
int val = 0;               // declaring variable for storing value of signal pin 

void setup()
     {
  
  // put your setup code here, to run once:
  
  Serial.begin(9600);      // setting baud rate for serial communication
  
  // tft Initialization 
  tft_init(INITR_GREENTAB);
  tft.setRotation(1);
  tft.fillScreen(ST7735_BLACK);

  pinMode(signalpin,INPUT);      // setting signal pin of touch sensor module as a input pin 

  tft.setCursor(20,20);                           // setting cursor at x =20 y= 20
  tft.setTextColor(ST7735_WHITE,ST7735_BLACK);   //setting text color WHITE on black  background
  tft.setTextSize(1.5);                         // setting text size to 1.5
  tft.print("    TOUCH SENSOR");               // printing text on TFT display 
  
     }

void loop() 
     {
         // put your main code here, to run repeatedly:

        val = digitalRead(signalpin);     // reading value signalpin
         
         // if value of signal pin is high then turn color
        //  of rectangle to green color otherwise red color
        
        if (val == HIGH)                
           {
             tft.fillRoundRect(30,40,100,70,10,ST7735_GREEN); // drawing and filling round rectangle with color
           }
        else
           {
             tft.fillRoundRect(30,40,100,70,10,ST7735_RED);
           }

}

Expected Result

Conclusion

In this lesson, we learned how to connect and use a Digital Capacitive Touch Sensor (TTP223B) with evive. We connected the VCC and GND pins of the TTP223B module to the evive board, and the SIG pin was connected to digital pin 8. We wrote an Arduino code that reads the value of the signal pin and turns the color of a round rectangle to green if the value is HIGH and red if the value is LOW. We also learned about the pin description of the TTP223B module and the circuit diagram for connecting it to evive.

Table of Contents