Wednesday, September 7, 2016

Arduino_KY-017_Mercury_open_optical_module

Arduino KY-017 Mercury open optical module

Mercury tilt switch that allows you to detect the tilt of your object.
Module also contains a status led.
One bad thing about this module is the toxic mercury.
As long as the glass bulb is closed it will give no problems.
This module needs to be disposed as toxic waste !

Hardware

  • S           Arduino Pin 3
  • middle   +5V
  • -           GND

Function

Arduino led (Pin 13) displays tilt status.

More info

Program

// ** Arduino KY-017 Mercury open optical module ** /* ** HARDWARE ** S Pin 3 middle +5V - GNF int buttonpin = 3; // define the mercury tilt switch sensor interface int Led = 13 ; // define LED Interface int val ; // define numeric variables val // *** SETUP *** void setup () { pinMode (Led, OUTPUT) ; // define LED as output interface pinMode (buttonpin, INPUT) ; // define the mercury tilt switch sensor output interface } // *** LOOP *** void loop () { val = digitalRead (buttonpin) ; // read the values assigned to the digital interface 3 val if (val == HIGH) // When the mercury tilt switch sensor detects a signal, LED flashes { digitalWrite (Led, HIGH); } else { digitalWrite (Led, LOW); } }

No comments: