Tilt Switch Module (KY-020) [S050]



https://www.youtube.com/watch?v=dVq5xSTB9S8


*GitHubhttps://github.com/rdiot/rdiot-s050.git


* Specs

Tilt sensor

Working voltage: 3.3V~5V

Digital Switch Output (0 & 1)

High sensitivity

With fixed bolt hole for easy installation

Works with Official Arduino Boards

Forum link: https://www.facebook.com/123Neonado

Material: PCB

Dimensions: 25 x 16 x 8 mm / 0.98 x 0.63 x 0.31 inch

Weight: 1 g / 0.04 oz

Color: Black


* Contents

- Connect

S ----- D2

middle ----- 5V

- ----- GND


- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

 

int pin = 2;

int val = digitalRead(pin);

 

  if(val == LOW)

  { 

    lcd.setCursor(0,2);

    lcd.print("Tilt CLOSE");

  }

  else

  {

    lcd.setCursor(0,2);

    lcd.print("Tilt OPEN ");  

  }

Posted by RDIoT

댓글을 달아 주세요