Difference between revisions of "Arduino Mercury Switch Breakout Module"

From Geeetech Wiki
Jump to: navigation, search
(Example code)
(Usage)
Line 13: Line 13:
 
[[File:Tilt wiring.jpg|500px]]
 
[[File:Tilt wiring.jpg|500px]]
  
VCC - 5V<br>
+
VCC - 5V
GND - GND<br>
+
GND - GND
S  - Digital pin3<br>
+
S  - Digital pin3
  
 
==Example code==
 
==Example code==

Revision as of 09:50, 14 May 2012

introduction

Tilt sensor.jpg

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.

Usage

Tilt wiring.jpg

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