Spark Core Light Clock

by kais58 in Circuits > Clocks

974 Views, 8 Favorites, 0 Comments

Spark Core Light Clock

2014 00:34.jpg

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

Setup Your Spark Core

2014 00:25.jpg
Follow the instructions provided when you got your core to set up and pair it to your account.

Attach Internet Button

2014 00:26.jpg

Slot the spark core into the Internet button

Use Web Page to Upload Code to Device

2014 00:26.jpg

// 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; }