Digital
Tilt
Sensor
SKU:DFR0028
Contents
1
Introduction
2
Specification
3
Connection
Diagram
o
3.1
Sample
Code
Introduction
The DFRobot Tilt Sensor is a digital tilt
sw
itch
. It could be used as a sim
ple tilt sensor. Simple
plug to our IO/Sensor Expansion board, you
can make amazing interactive projects. The
dedicated sensor expansion boa
rds with the Arduino, in combination, can achieve very
interesting and an interactive work.
Specification
Supply
Voltage:
3.3V
to
5V
Interface:
Digital
Size:22x30mm
Connection
Diagram
SampleCode
int ledPin = 13; // Connect LED to pin 13
int switcher = 3; // Connect Tilt sensor to Pin3
void setup() {
pinMode(ledPin, OUTPUT); // Set digital pin 13 to output mode
pinMode(switcher, INPUT); // Set digital pin 3 to input mode
}
void loop() {
if (digitalRead(switcher) == HIGH) //Read sensor value
digitalWrite(ledPin, HIGH); // Turn on LED when the sensor is tilted
else
digitalWrite(ledPin, LOW); // Turn off LED when the sensor is not trig
gered
}
Powered B
y DFRobot © 2008-2017
Suppliers Inquiry
Previous
Next
Link
Name *
Reason for Contact
General Inquiry
Place Order
Report Issue
Target Price (Option)
Email Address *
Message *
BOM / Attach Files (Option)
Maximum allowed file size is 10MB