Skip to content
This repository
tree: 8937fa4c35
Fetching contributors…

Cannot retrieve contributors at this time

file 134 lines (106 sloc) 3.667 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
/*

CheerLights!
CheerLights Channel --> ConnectPort X2 --> XBee --> Arduino --> GE Color Effect Lights
This sketch subscribes to the CheerLights ThingSpeak Channel and relays the
last command from the Internet to a strand of GE Color Effects Lights via the Digi
ConnectPort X2.
Arduino Requirements:
* Arduino base board
* XBee Shield (or breadboardable XBee)
* Arduino 1.0 IDE
* GEColorEffects Arduino 1.0 Library
http://www.digitalmisery.com/wp-content/uploads/2011/11/GEColorEffects-Arduino-1.0.zip
Addiontal Requirements:

* Ethernet port on Router
* DHCP enabled on Router
* ConnectPort X2 with XIG
* XBee Series 2 Radios (x2)
Created: Novemeber 29, 2011 by Hans Scharler - http://www.iamshadowlord.com
Additional Credits:
* http://www.digitalmisery.com
* http://www.deepdarc.com
* Networked On Air Light by Matt Richardson
To join the CheerLights project, visit http://www.cheerlights.com
*/

#include <GEColorEffects.h>

// Color Effects Setup
#define outPin 5 // Arduino pin # that's connected to the signal line on the GE Lights
#define lightCount 36 // Total # of lights on string (usually 50, 48, or 36)

static uint16_t c;

GEColorEffects lights(outPin, lightCount);

void setup() {
  lights.enumerate(); // Enumerate lights on string to enable individual bulb addressing
  delay(100);
  
  // Setup Serial
  Serial.begin(115200);
  delay(1000);
  
  Serial.flush();
  delay(1000);
}

void loop() {
    
  Serial.println("http://api.thingspeak.com/channels/1417/field/1/last.txt");
  delay(3000);
  
  // Process CheerLights Commands
  if(Serial.available() > 0)
  {
    delay(100);
    
    String response;
    char charIn;

    do {
        charIn = Serial.read(); // read a char from the buffer
        response += charIn; // append that char to the string response
      } while (Serial.available() > 0);
          
    // Send matching commands to the GE-35 Color Effect Lights
    if (response.indexOf("white") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_WHITE);
    }
    else if (response.indexOf("black") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_BLACK);
    }
    else if (response.indexOf("red") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_RED);
    }
    else if (response.indexOf("green") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_GREEN);
    }
    else if (response.indexOf("blue") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_BLUE);
    }
    else if (response.indexOf("cyan") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_CYAN);
    }
    else if (response.indexOf("magenta") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_MAGENTA);
    }
    else if (response.indexOf("yellow") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_YELLOW);
    }
    else if (response.indexOf("purple") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_PURPLE);
    }
    else if (response.indexOf("orange") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_ORANGE);
    }
    else if (response.indexOf("warmwhite") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_WARMWHITE);
    }
    else if (response.indexOf("black") > 0)
    {
        lights.fill_color(0, lightCount, DEFAULT_INTENSITY, COLOR_BLACK);
    }
    
    delay(1000);
    Serial.flush();
   
  }
  
  delay(10000);
  
} // End loop
Something went wrong with that request. Please try again.