Maker Pro
Arduino

Mercury Switch Tilt Sensor with Arduino

March 27, 2020 by Utsource Parts
Share
banner

Hi guys, in this instructables we will learn how to use Mercury Switch Tilt sensor with Arduino.

Introduction

A Tilt Sensor switch is an electronic device that detects the orientation of an object and gives its output High or Low accordingly. Basically, it has a mercury ball inside it which moves and makes the circuit. So tilt sensor can turn on or off the circuit based on the orientation.

In this project, we are interfacing Mercury switch / Tilt sensor with Arduino UNO. We are controlling a LED and buzzer according to the output of the tilt sensor. Whenever we tilt the sensor the alarm will be turned on. You can also see the working of tilt sensor in this tilt sensor circuit.

Components Required

  • Mercury Switch/ Tilt Sensor
  • Buzzer
  • LED
  • Resistor - 220 ohm
  • Arduino UNO
  • Connecting Wires
  • Breadboard

Schematic Diagram

tilt sensor 2.jpg


Connecting the Circuit

To connect a Tilt sensor with the Arduino, it requires 5v dc input to operate. That 5v is supplied using Arduino UNO and the output of Tilt sensor is taken at PIN 4 of the Arduino. LED is connected with the PIN 2 of the Arduino UNO with 220-ohm resistor to limit the current to a safe value. And, the buzzer is directly connected to the PIN 3 of the Arduino UNO.

Arduino Code

void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, INPUT);
}
void loop() {
if (digitalRead(4) == 1)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
delay(300);
}
}

Upload this code to your Arduino board.

Testing the Sensor

tilt sensor 3.jpg
tilt sensor 4.jpg

After connecting everything together and uploading the code to arduino IDE , whenever you will tilt the sensor then the buzzer will beep and the LED will blink according to the rotation of sensor.


Author

Avatar
Utsource Parts

share how to, diy, homemade, circuit design and new project ideas.

Related Content

Categories

Comments


You May Also Like