/**
 * Led blink using millis() 
 * by BARRAGAN <http://barraganstudio.com>
 * 
 * Demonstrates how to blink an LED at an interval rate using a timer
 */

int ledPin = 48;                // onboard LED          
int status = LOW;               // led status, initially LOW               
unsigned long previousTime;     // timer variable       
int interval = 5000;  // interval for blinking 5 seconds     

void setup()
{
  pinMode(ledPin, OUTPUT);   
  previousTime = millis();  // mark the time
}

void loop()
{
  // if current time - previousTime is greater than 5 seconds
  // change the LED status
  if((millis() - previousTime) > interval) {
    // invert the LED status 
    if (status == LOW) {
      status = HIGH;
    } 
    else {
      status = LOW;
    }
    digitalWrite(ledPin, status);
    previousTime = millis();   // mark the time
  }
}

