Arduino CI Build Light


So about 4 months ago, or last summer I built an Arduino powered build light for my new job. It was pretty cool but the problem was the base where the legs go in wasn’t sturdy enough (was made out of an old computer power supply). So I finally had some time today to fix that. I stopped at Lowes and actually found some large electric boxes and they even had a place to screw them together! I was excited! I got everything rewired and fixed. Took off another pipe at the top to make it not as top heavy. Here is a pic of the new and improved version of the build light.

Arduino Build Light

I got the idea and information on how to build one from an instructable called Arduino Build Warden. If you want to build your own I recommend following that guy’s instructable. It works great. The only difference in mine is I used all blue leds to make it more bright. Kmart Special!

One of my old coworkers after doing a lunch n learn on how the build light works wrote a new Arduino app to flicker the lights in a dim mode kind of like how your mac dims the little power light. We were able to work on it together and tweak it up a bit so it worked. Posted below is the arduino code that you upload to the board. It takes two commands. Alert and Off. Which you can send from your CI (hudson, jenkins) or even from the computer by writing to the serial port.


  #define slen 7 // 7 characters

// constants won't change. Used here to
// set pin numbers:
const int ledPin13 = 13;      // the number of the LED pin
const int ledPin12 = 12;
const int ledPin11 = 11;

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to blink (milliseconds)
boolean alert = false;

char serInStr[slen];  // array to hold the incoming serial string bytes


void setup() {
  // set the digital pin as output:
  pinMode(ledPin13, OUTPUT);
  pinMode(ledPin12, OUTPUT);
  pinMode(ledPin11, OUTPUT);

  Serial.begin(9600);

  turnOffLights();
}

unsigned int readInputTic = 0;
void loop()
{
  if (readInputTic == 20000)
  {
    int spos = readSerialString();

    if(spos != -1 && strncmp(serInStr, "alert", 5) == 0) {
       alert = true;
    }

    if(spos != -1 && strncmp(serInStr, "off", 3) == 0) {
       alert = false;
    }

    readInputTic = 0;
  }
  ++readInputTic;

  if(alert == true) {
    ledState = HIGH;
     doAlert();
  } else {
     turnOffLights();
  }
}

void turnOffLights() {
   if(ledState != LOW) {
     digitalWrite(ledPin13, LOW);
     digitalWrite(ledPin12, LOW);
     digitalWrite(ledPin11, LOW);
   }
}

float freq = 10;
float tic = 0;
float rot = 0;
void doAlert()
{
  if (tic == 0)
  {
   digitalWrite(ledPin13, HIGH);
   digitalWrite(ledPin12, HIGH);
   digitalWrite(ledPin11, HIGH);
  }
  else
  {
   digitalWrite(ledPin13, LOW);
   digitalWrite(ledPin12, LOW);
   digitalWrite(ledPin11, LOW);
  }

  rot += 0.1f;
  rot = (rot >= 360.0f) ? 0.0f : rot;
  freq = (1.0f - abs(cos(DegToRad(rot)))) * 10.0f;// / 100;

  tic += 0.1f;
  if (tic >= freq) tic = 0;
}

float DegToRad(float deg)
{
  return (deg / 360.0f) * 6.283185307179586476925286766559f;
}

int readSerialString () {
  int i = 0;
  if(!Serial.available()) {
    return -1;
  }
  while (Serial.available() && i < slen) {
    int c = Serial.read();
      serInStr[i++] = c;
  }
  Serial.println(serInStr);
  return i;
}

So in conclusion if you are sick of people breaking the build and not knowing they broke it. This should fix that. Let everyone on your team know it’s broken so the attention gets put on who broke the build and the embarrassment should make them fix it asap. </p>

Shoot me an email if you want me to build you one of these. But it's way more fun to build them yourself.