A Tilt sensor is a switch device that detects the change of orientation of an object and gives its output High or Low signal. The mercury tilt switch module uses a small mercury ball that open or close the circuit when you tilt the module. The output is HIGH when the mercury ball closes the circuit, and LOW when the mercury is placed away from the circuit
This module consists of a mercury switch, a 680 ohm resistor and an LED that will light up when tilt is detected. The mercury ball will open or close the circuit when the module is rotated or tilted. It has 3 pins, namely: signal (S), VCC and the GND. The signal pin should be connected to any digital pin of arduino. The VCC pin will be connected to the 5V of Arduino and the GND pin will be connected to the GND of the Arduino.
See below for the code example to test the Mercury Tilt Switch module
Upload and test the code in Arduino. The light on of led will turn on when the module is tilted. Enjoy tilting!