0% found this document useful (0 votes)
4 views3 pages

Tilt Switch Module

The Tilt Switch module outputs a high signal when tilted to the right and has three pins: Power, Ground, and Signal. It operates at 5V and is suitable for Arduino projects, with a size of 24.5*15.5mm and a weight of 1.350g. The document includes a code example for using the module to detect tilt and trigger an alarm state.

Uploaded by

pacho_1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Tilt Switch Module

The Tilt Switch module outputs a high signal when tilted to the right and has three pins: Power, Ground, and Signal. It operates at 5V and is suitable for Arduino projects, with a size of 24.5*15.5mm and a weight of 1.350g. The document includes a code example for using the module to detect tilt and trigger an alarm state.

Uploaded by

pacho_1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

pin. That’s an interesting function to your Arduino project.

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

lastShockTime = millis(); // record the time of the shock


if (!bAlarm)
{
[Link]("Shock module");
bAlarm = true;
}
else
{
if( (millis()-lastShockTime) > shockAlarmTime && bAlarm)
{ [Link]("no alarm");
bAlarm = false;
}
}
}

3/3

You might also like