Arduino Blog #8 TTP223 Touch Sensor

in #blog6 years ago

This tutorial is an open source arduino project that teaches how to control TTP223 touch key switch senosor module i am going to use LCD 16,2 with i2 backpack to display the data from the module

20180426_145209_HDR.jpg

Gather all the Requirements

1 pc Touch key switch module
Arduino Microcontroller board
16x2 LCD Display
Type B usb cable
PC
Breadboard
Jumper wires


20180426_145037_HDR.jpg

The 16x 2 LCD with I2C module you will be able to connect the LCD with Arduino board with only two Data cables! The i2c module has a built in potentiometer bakpack for contrast adjustment. The 16x2 display is the set up LCD number of columns and rows ( 16 columns, 2 rows Display ). has 4 build in backpack pins (1) VCC it refers to the power signal of the LCD typically connected to 5volts, (2)GND or sometimes zero voltage, It is also the common connection of the LCD must connect to in one way or another path in order to complete the circuit. (3) SDA and (4) SCL is the i2c serial bus pin it is used to synchronize all data transfers over the I2C bus from the 16 pin of the normal LCD, Both SCL and SDA are connected to analog pin ouputs of the arduino beacasue i2c lines are open drain drivers, means is that the chip can drive its output low.

Connection of LCD To Arduino

U5dtscBsyjBC5SyzpoZbaN8ZPJJuqi4_1680x8400.png

A touch sensor is a type of switch that only operates when it's touched by a charged body. It has a high-frequency transistor which can conduct electricity when receiving electromagnetic signals.
The Sensor has 4 pins the power pins GND / VCC , the analog pin AO and the Digital pin output D0, use the digital pin output DO for sensor pin of the module to arduino.

Connection of Touch sensor to Arduino

222.png

Dowload the arduino Desktop IDE: https://www.arduino.cc/en/Main/Software
When the download is finished, un-zip it and open up the Arduino folder to confirm that click yes, there are some files and sub-folders inside. The file structure is important so don’t be moving any files around unless you really know what you’re doing.

Download the liquidcrystal LCD library : https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library This library is a modified version of the H. Mario LiquidCrystal_I2C V.2.0 lib. then Include libraries to arduino IDE

SOURCE CODE

#include <Wire.h>  // include wire .h file 
#include <LiquidCrystal_I2C.h> //include lcd library
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 16X2 lcd display address
int pin = 2; // pin connection of metal touch
void setup()
{
  lcd.begin(16,2);  // initialize the lcd 
  lcd.backlight();
  lcd.print(" SENSOR "); // text to be displayed on the LCD when boot up
  pinMode(pin,INPUT);
  delay(1000); // delay time of the TEXt 1000 is equal to 1 seconds
  lcd.clear();
}
void loop()
{
  lcd.setCursor(1, 0); // first row cursor of the lcd
  lcd.print(" TOUCH SENSOR "); // text displayed on the lcd 
  int val = digitalRead(pin); // reads the value of the touchpin
  lcd.setCursor(0, 2); // 2nd row cursor
  if(true == IsTouchec(pin)) // Text that the sensor has been triggered
  {
    lcd.setCursor(0,2); // text displayed at the 2nd row of the LCD
    lcd.print("Sensor=Touch "); 
  }
  else // otherwise
  {    
    lcd.setCursor(0,2); // text displayed at the 2nd row of the LCD
    lcd.print("Sensor=None "); // text that the sensor is not triggered
  }
}
bool IsTouchec(int p)
{
 int time = 0;
 do
 {
   if (HIGH == digitalRead(p)) return true;
   delay(1);
 } while (time++<15);
 return false;
}

Once the code is successfully uploaded to the board touch the plated touch pad with your fingers, this should change the none touch to TOUCH on the LCD indicate that the sensor has been triggered. thats all folks, if you have question drop it down below the comment thanks.

20180426_145230_HDR.jpg


ee

Sort:  
Congratulations This post has been upvoted by SteemMakers. We are a community-based project that aims to support makers and DIYers on the blockchain in every way possible.

Join our Discord Channel to connect with us and nominate your own or somebody else's posts in our review channel.

Help us to reward you for making it ! Join our voting trail or delegate steem power to the community account.

Your post is also presented on the community website www.steemmakers.com where you can find other selected content.

If you like our work, please consider upvoting this comment to support the growth of our community. Thank you.

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.034
BTC 63578.68
ETH 3314.57
USDT 1.00
SBD 3.94