Today we are going to learn the following about touch switch based on TTP223.
- Pinout explanation
- Four different modes of the touch switch
- Connecting with LED
- Interfacing with Arduino
- Adjusting touch sensitivity
TTP223 Features
- Operating voltage 2.0V~5.5V
- Operating current @VDD = 3V, no load
- At low power mode typical 1.5uA, maximum 3.0uA
- The response time max 220mS at low power mode @VDD=3V
- Sensitivity can adjust by the capacitance(0~50pF) outside
- Stable touching detection of the human body for replacing traditional direct switch key
- Provides Low Power mode
- Provides direct mode、toggle mode by pad option(TOG pin) Q pin is CMOS output
- All output modes can be selected active high or active low by pad option(AHLB pin)
- After power-on have about 0.5sec stable-time, during the time do not touch the keypad, And the function is disabled
- Auto calibration for life.
- At low power mode, the re-calibration period is about 4.0sec normally,
- When key detected touch and released touch, the auto re-calibration will be redoing after about 16sec from releasing key
- The sensitivity of TTP223N-BA6 is better than TTP223-BA6’s. But the stability of TTP223N-BA6 is worse than TTP223-BA6’s.
Hardware Required
Touch switch configurations
There are four different configurations for this touch switch, which is explained below in details.
Config 1:
- To obtain configuration one both A and B terminals should be in open position.
- Default output state will be LOW
- Changes the state (to HIGH) when a touch is detected and will be back to the default state when touch is released
Config 2:
- To obtain configuration one both A should be open and B should be in close position.
- Default output state will be LOW
- Changes the state when a touch is detected and remains on that state until another touch is detected.
Config 3:
- To obtain configuration one both A should be close and B should be in open position.
- Default output state will be HIGH
- Changes the state (to LOW) when a touch is detected and will be back to the default state when touch is released
Config 4:
- To obtain configuration one both A and B terminals should be close position.
- Default output state will be HIGH
- Changes the state when a touch is detected and remains on that state until another touch is detected.
Adjusting touch sensitivity
Sensitivity can adjust by adding a capacitance, the value of capacitor ranges from 0 to 50 pf, where 0pf gives the full sensitivity and 50pf will gives the lowest sensitivity. For example, if you needed the touch switch to work through glass or acrylic you will need to adjust the sensitivity based on the thickness of the material.
Connecting with LED
Interfacing with Arduino
Arduino | Touch Sw |
---|---|
GND | GND |
5V | VCC |
D3 | I/O |
Watch the video to understand it better
Code
//www.diyusthad.com #define touchSw 4 void setup() { pinMode(touchSw,INPUT); Serial.begin(9600); } void loop() { boolean touchState; touchState = digitalRead(touchSw); Serial.println(touchState); if(touchState == HIGH) { //write statements to execute when the sw is high } else { //write statements to execute when the sw is low } }
To buy electronic components order from UTSOURCE