All posts tagged Arduino

After seeing this post last year about hacking GE Color Effects LED lights, I knew I had to get my hands on these.  Basically, they are the most awesome holiday lights ever.  They are pretty cool right out of the box, but with the protocol reverse-engineered, the possibilities are pretty much endless.  It didn’t take long for an Arduino port to surface and over the past year people have made good use of the fully addressable nature of these strings. I ran out and picked up some of the last strings available last season just in case GE decided to not make them again and was happy to see they are on sale again this year.

I’ve been playing with them on and off over the past few months and they are almost ready to make their debut for this holiday season.  In the process of creating software to control these light strings, I decided to stick with the Arduino platform since I’m pretty familiar with it now and it was quick and easy to implement.  The original code and the Arduino port worked well, but I needed a more modular implementation of the light driving code.  I ultimately created an Arduino library that simplifies the use of these lights.  It is based on those original code examples yet neatly wrapped into a library. I wanted to share it in case others were interested in playing with these awesome lights.

You can grab the library here: GE Color Effects Arduino Library (or if you are using the 1.0 version of the IDE: GEColorEffects Arduino 1.0) As with any other Arduino library, un-zip the file into your libraries folder in your Arduino installation directory. I have included a simple example sketch as well. See this page if you need additional help. As I mention in the library source comments, you may have to tweak the timing due to the imprecise nature of the DigitalWrite function, but the timing provided works well on my boards.  Have fun!

My BatchPCB order for the V2.0 Arduemetry boards as well as my new XBee GPS module has arrived.  Take a look at the pictures below.  I quickly soldered up the GPS module and it looks and works great.  I think it gets better reception now that it is on its own board with a good ground plane.  Definitely seems better than before when I had just soldered pins to the module and plugged it into a socket on my V1.0 board. Now I just need to find the time to assemble the V2.0 board and test it out.  After that’s up and running I’ll have to think of what to do next with this project – possibly make some more modules (sensors, antenna connectors, etc.) with the XBee footprint.  Any suggestions?

XBee GPS Module PCBs

XBee GPS Module PCBs

XBee GPS Module Bottom

XBee GPS Module Bottom

XBee GPS Module Top

XBee GPS Module Top

Arduemetry V2.0 PCBs

Arduemetry V2.0 PCBs

Here is the code I used on the receive side (Arduino USB board with Adafruit XBee adapter) connected to the steering servo and speed control on an old RC-10T truck:

#include "Servo.h"
#include "NewSoftSerial.h"

int joyx,joyy = 135;
int accx,accy = 125;
int zbut,cbut = 0;
int ledpin = 6;
int wheelServo = 9;
int motorServo = 10;
int lightvalue = 255;
char nunchuckData;
int val = 0;
int tempval = 0;
int wheelPos;
int motorPos;
int buttonState = 0;
int lightMode = 0;

Servo steer;
Servo move;

NewSoftSerial xbee(2,3);  //NewSoftSerial mySerial(int rx, int tx);

void setup()
//    Serial.begin(57600);
//    Serial.print("Nunchuck ready\n");

    pinMode(ledpin, OUTPUT);

void loop() {
  if (zbut) {
    if (joyy < 130) {
      motorPos = 92+((135-joyy)/5);
      if (motorPos > 135)
        motorPos = 135;
    if (joyy > 140) {
      motorPos = 92-((joyy-135)/5);
      if (motorPos < 45)
        motorPos = 45;
  else {
    if ((joyy > 130) && (joyy < 140)) {
  if (accx > 125) {
    wheelPos = 90-(accx-125);
    if (wheelPos < 45)
      wheelPos = 45;
  if (accx < 125) {
    wheelPos = 90+(125-accx);
    if (wheelPos > 135)
      wheelPos = 135;

  if (cbut != buttonState) {          // the button state has changed!
    if (cbut == 1) {                // check if the button is pressed
      if (lightMode == 0) {          // light is off
        lightMode = 1;               // light is on!
        digitalWrite(ledpin, HIGH);
      } else {
        lightMode = 0;               // light is on!
        digitalWrite(ledpin, LOW);
  buttonState = cbut;               // save the new state in our variable

  while(xbee.available()) {
    tempval =;
    if (tempval=='x')    {
    else if (tempval=='y')    {
    else if (tempval=='X')    {
    else if (tempval=='Y')    {
    else if (tempval=='Z')    {
    else if (tempval=='C')    {
    else if (tempval >='0' && tempval < = '9')    {
      val=val * 10;
      val=val + (tempval - '0');

      if (nunchuckData=='x'){
      else if (nunchuckData=='y'){
      else if (nunchuckData=='X'){
      else if (nunchuckData=='Y'){
      else if (nunchuckData=='Z'){
      else if (nunchuckData=='C'){
  }  //end of input in serial buffer

The NewSoftSerial library is a great way to use any two Arduino pins as another serial port.

Here is the code that I used on the Arduino Pro Mini in the Wireless Wii Nunchuck:

#include "Wire.h"
#include "nunchuck_funcs.h"

int loop_cnt=0;

byte accx,accy,zbut,cbut,joyy,joyx;
int ledPin = 13;

void setup()
    nunchuck_init(); // send the initilization handshake
    pinMode(ledPin, OUTPUT);

void loop()
  digitalWrite(ledPin, HIGH);   // set the LED on   

    if( loop_cnt > 50 ) { // every 100 msecs get new data
        accx = 120;
        accy = 120;

        loop_cnt = 0;


        accx  = nunchuck_accelx(); // ranges from approx 70 - 182
        accy  = nunchuck_accely(); // ranges from approx 65 - 173
        zbut = nunchuck_zbutton();
        cbut = nunchuck_cbutton();
        joyy = nunchuck_joyy();
        joyx = nunchuck_joyx();


And the nunchuck functions code can be found here.