Guest User

Untitled

a guest
Dec 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. const int ledPin = 13;// We will use the internal LED
  2. const int tiltSwitch = 2;// the pin our Tilt Switch is on
  3.  
  4. void setup()
  5. {
  6. pinMode(ledPin,OUTPUT); // Set the LED Pin as an output
  7. pinMode(tiltSwitch,INPUT_PULLUP); // Set the Tilt Switch as an input
  8. }
  9.  
  10. void loop()
  11. {
  12. int digitalVal = digitalRead(tiltSwitch); // Take a reading
  13.  
  14. if(HIGH == digitalVal)
  15. {
  16. digitalWrite(ledPin,LOW); //Turn the LED off
  17. }
  18. else
  19. {
  20. digitalWrite(ledPin,HIGH);//Turn the LED on
  21. }
  22. }
Add Comment
Please, Sign In to add comment