Skip to content

Instantly share code, notes, and snippets.

@mschlenker
Created April 2, 2016 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mschlenker/c0772d21753873df07b25acacb49a59e to your computer and use it in GitHub Desktop.
Save mschlenker/c0772d21753873df07b25acacb49a59e to your computer and use it in GitHub Desktop.
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 13
#define BLUE strip.Color(0,0,255)
#define BLACK strip.Color(0,0,0)
#define GREEN strip.Color(0,255,0)
#define RED strip.Color(255,0,0)
#define WHITE strip.Color(255,255,255)
#define PIXELOFFSET 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
strip.begin();
strip.show();
}
void loop() {
// put your min code here, to run repeatedly:
//strip.setPixelColor(6, BLUE);
//strip.show();
delay(3000);
for (int i=0; i<24; i++) {
for (int j=0; j<60; j++) {
for (int k=0; k<60; k++){
setClock(i, j, k);
delay(10);
}
}
}
}
void setClock (int hour, int minute, int sec) {
for(int i=0; i<12; i++){
strip.setPixelColor(i, BLACK);
}
strip.setPixelColor((sec/5+PIXELOFFSET)%12, RED);
strip.setPixelColor((minute/5+PIXELOFFSET)%12, BLUE);
strip.setPixelColor((hour+PIXELOFFSET)%12, WHITE);
strip.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment