Hello World! I made another example for one of the Sensors from my arsenal 🙂
This time the Arduino Mercury Switch Module KY-017.
We are going to turn on and off a lamp with it, the code is very basic and easy to understand.
Arduino Uno, I used the Robotdyn Uno as i always do. Until it breaks:) then i use a new one! lol
1 Channel relay KY-019
Mercury Switch Module KY-017
1 Led of any color you want.
Jumper wires MM/FF/FM
Lamp socket + Lamp and power cable (optional to add to the relay)
Author:Danny van den Brande, Arduinosensors.nl. BlueCore Tech.
This example will show you how a Arduino Mercury Switch works.
This example is very basic and easy to understand.
It will turn on a relay when tilting the switch.
You can add a lamp or any device to the relay.
int BlueLed = 9;
int KwikSwitch = 8;
int Relay = 7;
pinMode (BlueLed, OUTPUT);
pinMode (Relay, OUTPUT);
pinMode (KwikSwitch, INPUT);
val = digitalRead (KwikSwitch) ;
if (val == HIGH)
digitalWrite (BlueLed, HIGH);
digitalWrite (Relay, HIGH);
digitalWrite (BlueLed, LOW);
digitalWrite (Relay, LOW);
What is a mercury switch?
A mercury switch is a switch which opens and closes an electrical circuit when a small amount of the liquid metal mercury makes contact with metal electrodes to close the circuit. There are several different basic designs (tilt, displacement, radial, etc.) but they all share the common design strength of non-eroding switch contacts.
The most common is the “mercury tilt switch”. It is in one state (open or closed) when tilted one direction with respect to horizontal, and the other state when tilted the other direction. This is what older style thermostats used to turn a heater or air conditioner on or off.
The “mercury displacement switch” uses a ‘plunger’ dipping into a pool of mercury and thereby causing the level inside the container to rise to an elevated height where at least one electrode is present. This design is currently used as part of relays in industrial applications when high current loads need to be switched frequently. These relays use electromagnetic coils to pull steel sleeves inside hermetically sealed containers.