1. Hello, World - Spark Core

Now I know how to turn on/off the RGB LED. Let’s change color of the LED. Found a document at http://docs.spark.io/firmware/#libraries-rgb.
Okay, I need to call RGB.control(true) in setup() method and can change color by calling RGB.color(r, g, b) method.
Changing color periodically would be easy using rand() method.

int led = D0;  // The RGB LED

// This routine runs only once upon reset
void setup() {
  pinMode(led, OUTPUT);
  RGB.control(true);
}

int random(int minVal, int maxVal)
{
  return rand() % (maxVal - minVal + 1) + minVal;
}

int randomColor() {
    return random(0, 255);
}

// This routine gets called repeatedly, like once every 5-15 milliseconds.
void loop() {
  digitalWrite(led, HIGH);  // Turn ON the LED pins
  delay(50);
  RGB.color(255, randomColor(), randomColor());
  digitalWrite(led, LOW);
  delay(50);
}


https://github.com/higepon/Spark-Core-Examples/blob/master/1.LED%20change%20color.ino