Introduction: Spark Core Light Clock

Light based internet clock, image shows 12:30:45

Step 1: Setup Your Spark Core

Follow the instructions provided when you got your core to set up and pair it to your account.

Step 2: Attach Internet Button

Slot the spark core into the Internet button

Step 3: Use Web Page to Upload Code to Device

// This #include statement was automatically added by the Spark IDE.
#include "SparkButton/SparkButton.h"

#include "application.h"

/** * Declaring the variables. */ unsigned int nextTime = 0; // Next time to loop

SparkButton b = SparkButton();

int led2 = D7; // This one is the built-in tiny one to the right of the USB jack

void setup() { // Initialize D7 pin as output

pinMode(led2, OUTPUT); Serial.begin(9600); b.begin(); }

void loop() { if(Time.now() % 2) { digitalWrite(led2, HIGH);

} else { digitalWrite(led2, LOW); } if (nextTime > millis()) { return; }

int timestamp = Time.now(); int hour = Time.hourFormat12(timestamp); int minute = Time.minute(timestamp)/5; int second = Time.second(timestamp)/5; b.allLedsOff(); b.ledOn(hour, 32,0,0); b.ledOn(minute, 0,32,0); b.ledOn(second,0,0,32); if(second == minute) { b.ledOn(second,0,32,32); } if(second == hour) { b.ledOn(second, 32,0,32); } if(hour == minute) { b.ledOn(hour,32,32,0); } if(hour == minute && hour == second) { b.ledOn(hour, 32,32,32); } nextTime = millis() + 200; }