From 382cadae11b96c92d9a028aa3d9ae897f1b0047d Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Fri, 17 May 2013 00:07:50 +0300 Subject: Latest lpd8806 update with schemes and modes --- lpd8806/src/sketch.ino | 80 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/lpd8806/src/sketch.ino b/lpd8806/src/sketch.ino index 21b865f..b4431c3 100644 --- a/lpd8806/src/sketch.ino +++ b/lpd8806/src/sketch.ino @@ -25,19 +25,41 @@ LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin); // clock = pin B1. For Leonardo, this can ONLY be done on the ICSP pins. //LPD8806 strip = LPD8806(nLEDs); -uint32_t SCHEME[] = { +uint32_t SCHEMES[5][4] = { +{ strip.Color(117, 0, 27), strip.Color(127, 43, 0), strip.Color(0, 85, 57), strip.Color(41, 111, 0) -}; - -uint32_t SCHEME2[] = { +}, +{ strip.Color(99,0,62), strip.Color(124,0,9), strip.Color(53,5,85), strip.Color(84,120,0) -}; +}, +{ + strip.Color(127,95,0), + strip.Color(41,7,86), + strip.Color(41,7,86), + strip.Color(5,48,82) +}, +{ + strip.Color(0,93,31), + strip.Color(3,60,79), + strip.Color(67,117,0), + strip.Color(127,20,0) +}, +{ + strip.Color(79,119,0), + strip.Color(0,102,0), + strip.Color(127,0,0), + strip.Color(102,0,58) +}}; + +int mode; +unsigned long last; +uint32_t* scheme; void setup() { // Start up the LED strip @@ -45,14 +67,27 @@ void setup() { // Update the strip, to start they are all 'off' strip.show(); + + randomSeed(analogRead(0)); + mode = 1; + scheme = SCHEMES[random(5)]; + last = 0; } void loop() { - colorChase(); + unsigned long t = millis(); + if (t - last > 25000) { + mode = (mode + 1) % 2; + scheme = SCHEMES[random(5)]; + last = t; + } + if (mode == 0) + chase(scheme); + else if (mode == 1) + sparkle(scheme); } -// Chase one dot down the full strip. Good for testing purposes. -void colorChase() { +void sparkle(uint32_t* scheme) { int i; uint32_t c; uint8_t wait; @@ -62,13 +97,40 @@ void colorChase() { // Then display one pixel at a time: for(i=0; i