Difference between revisions of "Arduino Mercury Switch Breakout Module"
From Geeetech Wiki
(→Usage) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
==Features== | ==Features== | ||
They are small, inexpensive, low-power and easy to use. Their simplicity make them popular for toy , gadget and appliances and many other application. | They are small, inexpensive, low-power and easy to use. Their simplicity make them popular for toy , gadget and appliances and many other application. | ||
+ | |||
+ | ==Pin definition== | ||
+ | [[File:Tilt 1.jpg]] | ||
==Usage== | ==Usage== | ||
− | [[File:Tilt wiring.jpg]] | + | [[File:Tilt wiring.jpg|500px]] |
− | VCC - 5V | + | VCC - 5V |
− | GND - GND | + | GND - GND |
− | S - Digital pin3 | + | S - Digital pin3 |
==Example code== | ==Example code== | ||
− | int ledPin = 13; // Connect LED to pin 13 | + | int ledPin = 13; // Connect LED to pin 13 |
− | int switcher = 3; // Connect Tilt sensor to Pin3 | + | int switcher = 3; // Connect Tilt sensor to Pin3 |
− | + | void setup() | |
− | void setup() | + | { |
− | { | ||
pinMode(ledPin, OUTPUT); // Set digital pin 13 to output mode | pinMode(ledPin, OUTPUT); // Set digital pin 13 to output mode | ||
pinMode(switcher, INPUT); // Set digital pin 3 to input mode | pinMode(switcher, INPUT); // Set digital pin 3 to input mode | ||
− | } | + | } |
− | void loop() | + | void loop() |
− | { | + | { |
if(digitalRead(switcher)==HIGH) //Read sensor value | if(digitalRead(switcher)==HIGH) //Read sensor value | ||
Line 37: | Line 39: | ||
digitalWrite(ledPin, LOW); // Turn off LED when the sensor is not triggered | digitalWrite(ledPin, LOW); // Turn off LED when the sensor is not triggered | ||
} | } | ||
− | } | + | } |
==How to buy it== | ==How to buy it== | ||
Click here to buy [http://www.geeetech.com/arduino-mercury-switch-breakout-module-p-393.html Tilt sensor module] | Click here to buy [http://www.geeetech.com/arduino-mercury-switch-breakout-module-p-393.html Tilt sensor module] |
Latest revision as of 09:55, 14 May 2012
introduction
The Tilt sensor is a digital mercury-based tilt sensor which allows you to detect orientation and inclination. It acts like a switch. When the tilt sensor is in horizontal position, it’s open. When tilt, the switch closed and pass current.
Note
Mercury is toxic substance, Please be careful to avoid breaking the case.
Features
They are small, inexpensive, low-power and easy to use. Their simplicity make them popular for toy , gadget and appliances and many other application.
Pin definition
Usage
VCC - 5V GND - GND S - Digital pin3
Example code
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 triggered } }
How to buy it
Click here to buy Tilt sensor module