Tilt Switch Module
Tilt Switch Module
DESCRIPTION:
This module is a tilt switch module, and if it is tilted towards right side ,it output one High level
signal. Be similar with our most sensor, It has three pin: Power pin, Ground pin and signal switch
Specification:
● Operation voltage: 5V
● 3Pin
● Size:24.5*15.5mm
● Weight: 1.350g
1/3
PIN CONFIGURATION:
1、 “S”: Signal pin
2、 “+” : +5V
3、 “-”: GND
Example:
This example show you how to use this module, connection as below, and upload the
sketch, rotate this module, see what will be happen.
Code:
int shockPin = 10; // Use Pin 10 as our Input
int shockVal = HIGH; // This is where we record our shock measurement
boolean bAlarm = false;
unsigned long lastShockTime; //Record the time that we measured a shock
int shockAlarmTime = 250; //Number of milli seconds to keep the shock alarm high
void setup ()
{
[Link](9600);
pinMode (shockPin, INPUT) ;
2/3
}
void loop ()
{
shockVal = digitalRead (shockPin) ; // read the value from our sensor
if (shockVal == LOW) // If we're in an alarm state
3/3