Metal Touch Sensor Module [S042]
https://www.youtube.com/watch?v=rF92w77SAuI
*GitHub : https://github.com/rdiot/rdiot-s042.git
* Specs
Color: red
Main chip: LM393
Operating voltage: DC 5V
Light weight design
With single channel signal output
Low level output signal used for human body touch sensor alarm
Compatible with Arduino
* Contents
- Connect
A0 ----- X
G ----- GND
+ ----- 5V
D0 ----- D2
- Key Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int pin = 2;
LiquidCrystal_I2C lcd(0x27,20,4); // LCD2004
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print("start LCD2004");
pinMode(pin,INPUT);
delay(1000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("S042:Metal Touch");
int val = digitalRead(pin);
lcd.setCursor(0,1);
lcd.print("digital=" + (String)val + " ");
if(true == IsTouchec(pin))
{
lcd.setCursor(0,2);
lcd.print("IsTouch=Touched ");
}
else
{
lcd.setCursor(0,2);
lcd.print("IsTouch=None ");
}
}
bool IsTouchec(int p)
{
int time = 0;
do
{
if (HIGH == digitalRead(p)) return true;
delay(1);
} while (time++<15);
return false;
}
'2) Sensor > Touch' 카테고리의 다른 글
Digital Touch Sensor Module Capacitive Switch [S243] (0) | 2017.02.28 |
---|---|
Catalex Capacitive Touch Sensor (TTP223B) [S009] (0) | 2016.09.12 |