Wednesday, March 25, 2009

Soldering is complete




I used a RBBB (an Arduino runtime module, cheap!) mounted on a soldered breadboard. Also, two RJ45 connectors on SparkFun breakout boards. That will make a clean connection for a pair of cat5 wires going up to the ceiling. I had originally planned on using screw terminals, but then I decided to use twisted wire pairs (signal, gnd) and needed twice as many connections. There was enough unused space on the board for every other pin to be a ground with these breakouts.

Next, I have to finish wiring up the LEDs and mount them to the little hot air balloons.

Prototype complete



For my Arduino-powered flickering LED project, I finished the prototype with all the features I wanted:
  1. Light sensor to turn the LEDs off after the room lights are turned off.
  2. Button to set the room darkness threshold, since I don’t want to have to reprogram the chip in the future.
  3. Six LEDs with flickering brightness.
  4. One steady LED for a differently shaped balloon, which will be used for the status display as well (blink to indicate setting the threshold, as well as to indicate that it noticed the lights went out).

Flickering LEDs - proof of concept

My first project is to light a string of papier-mâché hot air balloons. I was just going to light them with some LEDs, but then I heard about the Arduino and wanted to make something more exciting. I got a starter kit from adafruit.com and got to work.

This is the first proof of concept of making the LEDs flicker. Later I’ll add a light sensor to start a sleep timer that will turn the balloons off after a half hour.



Here’s the sketch that runs what you see above:

/*
* randomly flickering LEDs
*/

int ledPin[] = {
5, 6, 9, 10, 11}; // pwm pins only
int ledState[5]; // last state of each led
long randNumber;

void setup() {
for (int i=0; i<5; i++){ // set each led pin as an output
pinMode(ledPin[i], OUTPUT);
}
randomSeed(analogRead(0)); // seed the rnd generator with noise from unused pin

for (int i=0; i<5; i++){ // init each led with a random value
ledState[i] = random(20, 201);
}
}

void loop(){
for (int i=0; i<5; i++){ // for each led:
analogWrite(ledPin[i], ledState[i]); // set the pwm value of that pin determined previously
randNumber = random(-35, 41); // generate new random number and add that to the current value
ledState[i] += randNumber; // that range can be tweaked to change the intensity of the flickering
if (ledState[i] > 200) { // now clamp the limits of the pwm values so it remains within
ledState[i] = 200; // a pleasing range as well as the pwm range
}
if (ledState[i] < 10) {
ledState[i] = 10;
}
}
delay(100); // the delay between changes
}