Skip to content

Instantly share code, notes, and snippets.

@jonathanhculver
Last active December 10, 2015 01:18
Show Gist options
  • Save jonathanhculver/4357808 to your computer and use it in GitHub Desktop.
Save jonathanhculver/4357808 to your computer and use it in GitHub Desktop.
Collision effect for hacked Christmas lights
/*
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);
void setup() {
lights.fill_color(0, LIGHT_COUNT, 0, COLOR_RED);
}
void loop() {
for(int i=1; i<12; i=i+1) {
lights.fill_color(i, 1, G35::MAX_INTENSITY, COLOR_RED);
lights.fill_color(24-i, 1, G35::MAX_INTENSITY, COLOR_GREEN);
delay(100);
lights.fill_color(i, 1, 0, COLOR_RED);
lights.fill_color(24-i, 1, 0, COLOR_GREEN);
}
//collision
lights.fill_color(0, LIGHT_COUNT, G35::MAX_INTENSITY, COLOR_VIOLET);
delay(100);
lights.fill_color(0, LIGHT_COUNT, 0, COLOR_RED);
for(int i=12; i<25; i=i+1) {
lights.fill_color(i, 1, G35::MAX_INTENSITY, COLOR_RED);
lights.fill_color(24-i, 1, G35::MAX_INTENSITY, COLOR_GREEN);
delay(100);
lights.fill_color(i, 1, 0, COLOR_RED);
lights.fill_color(24-i, 1, 0, COLOR_GREEN);
}
//reverse direction
for(int i=23; i>12; i=i-1) {
lights.fill_color(i, 1, G35::MAX_INTENSITY, COLOR_RED);
lights.fill_color(24-i, 1, G35::MAX_INTENSITY, COLOR_GREEN);
delay(100);
lights.fill_color(i, 1, 0, COLOR_RED);
lights.fill_color(24-i, 1, 0, COLOR_GREEN);
}
//collision
lights.fill_color(0, LIGHT_COUNT, G35::MAX_INTENSITY, COLOR_ORANGE);
delay(100);
lights.fill_color(0, LIGHT_COUNT, 0, COLOR_RED);
for(int i=12; i>-1; i=i-1) {
lights.fill_color(i, 1, G35::MAX_INTENSITY, COLOR_RED);
lights.fill_color(24-i, 1, G35::MAX_INTENSITY, COLOR_GREEN);
delay(100);
lights.fill_color(i, 1, 0, COLOR_RED);
lights.fill_color(24-i, 1, 0, COLOR_GREEN);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment