Blue PCB Electronics
2C16 Mercury tilt switch module for Arduino KY-017
2C16 Mercury tilt switch module for Arduino KY-017
Couldn't load pickup availability
Share


Description
A mercury tilt switch module for Arduino is a device that allows you to detect changes in tilt or orientation. It is especially useful in projects where it is necessary to detect when an object or surface is tilted at a certain angle. The Ky-017 mercury tilt switch module can be used with an Arduino board to read data and respond to changes in tilt. It is a versatile device that can be used in numerous applications, including robotics, automation, and outdoor monitoring systems. It is also relatively easy to use, and the module is compatible with other Arduino sensors, making it a popular choice among hobbyists and professionals alike.
Arduino KY-017 mercury tilt switch module, it uses a small mercury ball that completes the circuit when you tilt the module.Â


Specifications
This module consists of a mercury switch, a 680Ω resistor and a LED that will light up when tilt is detected. The mercury ball will open/close the circuit when the module is rotated.
Operating Voltage | 3.3V to 5.5V |
KY-017 Connection Diagram
Connect the Power line (middle) and ground (-) to +5 and GND respectively. Connect signal (S) to pin 3Â on the Arduino.
KY-017 | Arduino |
S | Pin 3 |
middle | +5V |
- | GND |

KY-017 Arduino Code
The following sketch will light up the led on pin 13 of the Arduino when the module is tilted.
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);
}
}