Advertisement
inventrkits

tilt

Jan 22nd, 2020
569
0
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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement