Introduction
The KY-017 Mercury Tilt Switch module is a low-cost sensor module that detects the tilt or movement of the module. It contains a small mercury switch that moves inside the sensor when the module is tilted, and this movement is detected by the module. It can be used in a wide range of applications. Its ease of use and low cost make it an attractive option for hobbyists, students, and makers who want to add tilt-sensing capabilities to their projects.
The KY-017 Mercury Tilt Switch module is a simple and low-cost module that is easy to use with microcontrollers like Arduino and Raspberry Pi. It has three pins for connecting with external devices: VCC, GND, and S (Signal). The output of the module is a digital signal (0 or 1) that indicates whether the module is tilted or not. the KY-020 Tilt Switch Sensor Module.
Hardware Required
You will require the following Hardware Components for the Interfacing of the KY-017 Mercury Tilt Switch module with arduino.
Components | # | Buy From Amazon |
---|---|---|
Arduino UNO | 1 | Buy Link |
KY-017 Mercury Tilt Switch module | 1 | Buy Link |
LED 5mm | 1 | Buy Link |
Jumper Wires | – | Buy Link |
Breadboard | 1 | Buy Link |
Specifications
This module contains a 680Ω resistor, a mercury switch, 3 header pins, and a LED that will turn on when tilt is detected. The mercury ball will open/close the circuit when the module is rotated.
Operating Voltage | 3.3V ~ 5.5V |
Pinout
Pin Configuration
Pin Name | Pin Type |
---|---|
S | Signal Pin |
Middle | Power Pin, VCC |
( – ) | Ground Pin |
Circuit Diagram
The following circuit shows you the connection of the KY-017 Mercury Tilt Switch module with Arduino Please make the connection carefully
Circuit Connections
Place the module on the Breadboard and connect the Power line (middle) and ground (-) of the module to +5 and GND of the arduino and then connect signal pin (S) to pin 3 on the arduino respectively
Arduino | Module | LED |
---|---|---|
Pin 3 | S Pin | |
+5V | Middle Pin | |
Pin 13 | +Ve | |
GND | – Pin | -Ve |
Installing Arduino IDE Software
First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow
Code
The following code will switch on the LED on pin 13 of the Arduino when the module tilt degree changes. Tilt the module to turn the LED on/off.
//For more Projects: www.arduinocircuit.com
int led_pin = 13; // Define the LED interface
int switch_pin = 3; // Definition of mercury tilt switch sensor interface
int val; // Defines a numeric variable
void setup()
{
pinMode(led_pin, OUTPUT);
pinMode(switch_pin, INPUT);
}
void loop()
{
val = digitalRead(switch_pin); // check mercury switch state
if(val == HIGH)
{
digitalWrite(led_pin, HIGH);
}
else
{
digitalWrite(led_pin, LOW);
}
}
Applications
- Security Systems: The KY-017 module can be used in security systems to detect movement or tilting of doors and windows. It can be used to trigger alarms or alert the authorities of a potential intrusion.
- Game Controller: The module can be used in-game controllers to provide tilt-sensing capabilities. It can be used to control the movements of characters in a game or for other gaming functions.
- Robotics: The module can be used in robotics to detect the tilting or movement of robots. This can be used to control the movements of the robots or to trigger certain actions.
- Lighting Control: The module can be used to control lighting in homes and offices. It can be used to turn lights on or off when a door or window is opened or closed.
- Industrial Applications: The module can be used in industrial applications to detect the tilting or movement of heavy equipment or machinery. It can be used to trigger alarms or to shut down the equipment in case of a malfunction.