Last active
December 10, 2015 01:18
-
-
Save jonathanhculver/4357804 to your computer and use it in GitHub Desktop.
Tail effect for hacked Christmas lights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
G35: An Arduino library for GE Color Effects G-35 holiday lights. | |
Copyright © 2011 The G35 Authors. Use, modification, and distribution are | |
subject to the BSD license as described in the accompanying LICENSE file. | |
*/ | |
#include <G35String.h> | |
#define LIGHT_COUNT (25) | |
#define G35_PIN (13) | |
G35String lights(G35_PIN, LIGHT_COUNT); | |
byte one = 0x7F; | |
byte two = 0x64; | |
byte three= 0x20; | |
char colorArray[12] = {COLOR_WHITE, COLOR_RED, COLOR_GREEN, COLOR_CYAN, COLOR_MAGENTA, COLOR_YELLOW, COLOR_PURPLE, COLOR_ORANGE, COLOR_PALE_ORANGE, COLOR_WARMWHITE, COLOR_INDIGO, COLOR_VIOLET}; | |
int num = 0; | |
void setup() { | |
lights.fill_color(0, LIGHT_COUNT, 0, COLOR_BLUE); | |
lights.fill_color(0, LIGHT_COUNT, G35::MAX_INTENSITY, COLOR_BLUE); | |
delay(1000); | |
} | |
void loop() { | |
num = random(0,12); | |
for(int i=1; i<25; i=i+1) { | |
lights.fill_color(i, 1, G35::MAX_INTENSITY, colorArray[num]); | |
if(i>1) { | |
lights.fill_color(i-1, 1, two, colorArray[num]); | |
} | |
if(i > 2) { | |
lights.fill_color(i-2, 1, three, colorArray[num]); | |
} | |
delay(50); | |
lights.fill_color(i, 1, two, colorArray[num]); | |
lights.fill_color(i-1, 1, three, colorArray[num]); | |
lights.fill_color(i-2, 1, 0, colorArray[num]); | |
} | |
//reverse direction | |
num = random(0,12); | |
for(int i=23; i>-1; i=i-1) { | |
lights.fill_color(i, 1, G35::MAX_INTENSITY, colorArray[num]); | |
if(i < 23) { | |
lights.fill_color(i+1, 1, two, colorArray[num]); | |
} | |
if(i <22) { | |
lights.fill_color(i+2, 1, three, colorArray[num]); | |
} | |
delay(50); | |
lights.fill_color(i, 1, two, colorArray[num]); | |
if(i < 24) { | |
lights.fill_color(i+1, 1, three, colorArray[num]); | |
} | |
if(i < 23) { | |
lights.fill_color(i+2, 1, 0, colorArray[num]); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment