Advertisement
Guest User

Untitled

a guest
May 6th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. {
  2.   // here is where you'd put code that needs to be running all the time.
  3.  
  4.   // check to see if it's time to blink the LED; that is, if the
  5.   // difference between the current time and last time you blinked
  6.   // the LED is bigger than the interval at which you want to
  7.   // blink the LED.
  8.   unsigned long currentMillis = millis();
  9.  
  10.   if(currentMillis - previousMillis > interval) {
  11.     // save the last time you blinked the LED
  12.     previousMillis = currentMillis;  
  13.  
  14.     // if the LED is off turn it on and vice-versa:
  15.     if (ledState == LOW)
  16.       ledState = HIGH;
  17.     else
  18.       ledState = LOW;
  19.  
  20.     // set the LED with the ledState of the variable:
  21.     digitalWrite(ledPin, ledState);
  22.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement