Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int ledPin = 13;// We will use the internal LED
- const int tiltSwitch = 2;// the pin our Tilt Switch is on
- void setup()
- {
- pinMode(ledPin,OUTPUT); // Set the LED Pin as an output
- pinMode(tiltSwitch,INPUT_PULLUP); // Set the Tilt Switch as an input
- }
- void loop()
- {
- int digitalVal = digitalRead(tiltSwitch); // Take a reading
- if(HIGH == digitalVal)
- {
- digitalWrite(ledPin,LOW); //Turn the LED off
- }
- else
- {
- digitalWrite(ledPin,HIGH);//Turn the LED on
- }
- }
Add Comment
Please, Sign In to add comment