SHARE
TWEET

tilt

inventrkits Jan 22nd, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //KY017 Mercury open optical module
  2. int Led = 13 ;// define LED Interface
  3. int buttonpin = 3; // define the mercury tilt switch sensor interface
  4. int val ;// define numeric variables val
  5. void setup ()
  6. {
  7.   pinMode (Led, OUTPUT) ;// define LED as output interface
  8.   pinMode (buttonpin, INPUT) ;// define the mercury tilt switch sensor output interface
  9. }
  10. void loop ()
  11. {
  12.   val = digitalRead (buttonpin) ;// read the values assigned to the digital interface 3 val
  13.   if (val == HIGH) // When the mercury tilt switch sensor detects a signal, LED flashes
  14.   {
  15.     digitalWrite (Led, HIGH);
  16.   }
  17.   else
  18.   {
  19.     digitalWrite (Led, LOW);
  20.   }
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top