So I am charting new territories with my latest project… timing. I asked Adafruit to make a 60 LED NeoPixel ring and so now I can build my clock! I am working through some concepts dealing with timing and animation before I add Wifi or GPS to capture time.
Currently I am just using the Arduino time library to show the hours, minutes, seconds on the ring. Pretty basic. I just keep pushing the data to the Neopixel in every loop and the time just correlates directly.
#include <Adafruit_NeoPixel.h> // http://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library
#include <Time.h> // http://playground.arduino.cc/Code/Time
// NeoPixel Strip Data Out
#define PIN 6
// NeoPixel Decleration
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
// Color Definitions
uint32_t black = strip.Color(0, 0, 0);
uint32_t red = strip.Color(255, 0, 0);
uint32_t green = strip.Color(0, 255, 0);
uint32_t blue = strip.Color(0, 0, 255);
uint32_t white = strip.Color(255, 255, 255);
void setup() {
// Initialize the NeoPixel
strip.begin();
strip.show();
// Too damn bright
strip.setBrightness(64);
// Set internal time keeping as handled by the Time Library
setTime(23,13,20,24,3,2014);
}
void loop() {
// Set the layers of the clock and repeat
clockFace(black,white);
strip.setPixelColor(second(), blue);
strip.setPixelColor(minute(), green);
strip.setPixelColor(hourFormat12()*5, red);
strip.show();
}
void clockFace(uint32_t back, uint32_t mark){
for (uint16_t i=0; i < strip.numPixels(); i++) {
if(i%5 == 0) {
strip.setPixelColor(i, mark);
} else {
strip.setPixelColor(i, back);
}
}
}
https://www.dropbox.com/s/sqv97v7z2600h … .47.18.jpg
What I need some guidance is how to do animation, these are timed events. For example, if I want to have the seconds hand fade out and fade into the next position. How do I make the event happen exactly in that second? It seems to in-deterministic of a loop to appropriately do this because I would have to know how fast my loops should occur and will occur to add and subtract the appropriate fade in and fade out.
Suggestions?
Thanks,
Frank