Blinks Tutorial
Examples are great, but sometimes a tutorial is what the doctor ordered. In this tutorial, we’ll program two applications for Blinks, one that builds on the previous one. You should be able to follow the code line by line and hopefully learn a thing or two in the process.

/*
 * Your very first Blinks application
 */
void setup() {
  // this only happens once
}

void loop() {
  // this happens over and over again
  // the rate can be variable, but it will happen at 
  // a maximum the refresh rate of the display (~66Hz)
}

Lets make a Blink blink!


  1. create needed variables
Timer blinkTimer;
bool isBlinkOn;

  1. initialize variables
void setup() {
  blinkTimer.set(500);
  isBlinkOn = false;
}

  1. if the timer expires, update the status, on or off
void loop() {
  if(blinkTimer.isExpired()) {
    isBlinkOn = !isBlinkOn;
    blinkTimer.set(500);
  }
}

  1. now set our display, should it be on or off
void loop() {
...
  if(isBlinkOn) {
    setColor(RED);
  }
  else {
    setColor(OFF);
  }
}

The entire application looks like:

/*