Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 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.
- See README for complete attributions.
- */
- #include <MyG35String.h>
- // Total # of lights on string (usually 25 - 50). Maximum is 63, because
- // the protocol uses 6-bit addressing and bulb #63 is reserved for broadcast
- // messages.
- #define LIGHT_COUNT (25)
- // Arduino pin number. Pin 13 will blink the on-board LED.
- #define G35_PIN (13)
- G35String lights(G35_PIN, LIGHT_COUNT);
- void setup() {
- lights.enumerate();
- lights.do_test_patterns();
- delay(1000);
- candycane();
- delay(5000);
- pileup();
- delay(5000);
- }
- void loop() {
- lights.fill_color(0, LIGHT_COUNT, G35::MAX_INTENSITY, COLOR_RED);
- delay(1000);
- lights.fill_color(0, LIGHT_COUNT, G35::MAX_INTENSITY, COLOR_GREEN);
- delay(1000);
- candycane();
- delay(5000);
- pileup();
- delay(5000);
- static uint16_t c;
- lights.fill_color(0, LIGHT_COUNT, G35::MAX_INTENSITY, G35::rainbow_color(c++));
- delay(1000);
- }
- void test_pattern() {
- // Tickle the ends. You should see three reds at the start, and three greens
- // at the end. This confirms that you've properly configured the strand
- // lengths and directions.
- uint8_t last_light = LIGHT_COUNT - 1;
- uint8_t BROADCAST_BULB = 63;
- uint8_t MAX_INTENSITY = 255;
- for (int i = 0; i < 8; ++i) {
- for (int j = 0; j < 3; ++j) {
- lights.set_color(BROADCAST_BULB, 0, COLOR_BLACK);
- lights.set_color(j, MAX_INTENSITY, COLOR_RED);
- lights.set_color(last_light - j, MAX_INTENSITY, COLOR_GREEN);
- delay(250);
- }
- }
- }
- void pileup() {
- // LEDs Converge on the center from both ends
- uint8_t last_light = LIGHT_COUNT - 1;
- uint8_t BROADCAST_BULB = 63;
- uint8_t MAX_INTENSITY = 255;
- for (int sequence = 0; sequence < 30; ++ sequence) {
- lights.set_color(BROADCAST_BULB, 0, COLOR_BLACK);
- for (int frame = 0; frame < last_light; ++frame) {
- lights.set_color(BROADCAST_BULB, 0, COLOR_BLACK);
- for (int j = 0; j < last_light / 2; ++j) {
- // lights.set_color(BROADCAST_BULB, 0, COLOR_BLACK);
- lights.set_color(j, MAX_INTENSITY, COLOR_GREEN); // SET COLOR FROM BEGINNING;
- lights.set_color(last_light - j, MAX_INTENSITY, COLOR_RED); // SET COLOR FROM THE END;
- delay (100); // PAUSE BETWEEN ITEMS;
- }
- lights.set_color(last_light / 2, MAX_INTENSITY, COLOR_WHITE); // SET COLOR IN MIDDLE;
- delay(500); // PAUSE BETWEEN FRAMES;
- }
- } // COUNT NUMBER OF SEQUENCES;
- }
- void candycane() {
- // LED Movine Stripes
- uint8_t last_light = LIGHT_COUNT - 1;
- uint8_t BROADCAST_BULB = 63;
- uint8_t MAX_INTENSITY = 255;
- uint8_t numPixels = LIGHT_COUNT;
- int num_sets = 30;
- int Width = 4;
- int L = 0;
- for (int set = 0; set < num_sets; ++ set) {
- // lights.set_color(BROADCAST_BULB, 0, COLOR_BLACK);// RESET ALL LEDs OFF
- for (int frame = 0; frame < last_light; ++frame) {
- // lights.set_color(BROADCAST_BULB, 0, COLOR_BLACK);
- for (int i = 0; i < numPixels; i++) {
- L = numPixels - i - 1; // Which Pixel to Update;
- if ( ((frame + i) % ((Width * 2)) ) < (Width) ) {
- lights.set_color(L, MAX_INTENSITY, COLOR_RED); // SET PIXEL L COLOR TO RED
- } else {
- lights.set_color(L, MAX_INTENSITY, COLOR_GREEN); // SET PIXEL L COLOR TO WHITE
- }
- delay (10); // PAUSE BETWEEN ITEMS;
- }
- delay(10); // PAUSE BETWEEN FRAMES; }
- }
- } // COUNT NUMBER OF SETS;
- } // END FUNCTION CANDYCANE
Advertisement
Add Comment
Please, Sign In to add comment