blinky lights test

About a year ago, Interlock members were offered to go in on two group purchases, coordinated through the mailing list. The first was for Freeduino kits, with the boards pre-populated with the USB controller chip and mini-B socket. The second was for strands of individually-addressable RGB LEDs which can be controlled with an Arduino using this
Adafruit WS2801 library.

I indulged in each, getting one Freeduino kit as a soldering-skills confidence-building project and to give me a second Arduino-compatible device in case I wanted to start do something possibly destructive of my “store-bought” name-brand Arduino. I also got a single 50-light strand of the LEDs.

Well, as it turns out, I didn’t solder together the Freeduino until a couple of months ago. But I started playing with the LEDs almost right away, demonstrating them at our open house in the spring. I haven’t done a whole lot with them, other than play around with the color space a little bit by having them display cyan, magenta, and yellow (eg, the combinations of the other two colors leaving out, respectively, red, green, and blue).

The main problem I had starting out was that I wasn’t quite ready yet to start messing with external DC power supplies capable of delivering more than the half-amp or so that a USB port can supply. Reportedly, each LED can draw up to 60 milliamps, so there was no way I could use the out-of-the-box example code from the library, which lights up all the lights in the strand.

I could have had it just light up a half-dozen or so of the lights, I suppose, but I wanted to try all the lights, just not at once. I soldered onto the end of each of the four wires a bit of lead clipped from through-hole parts for other soldering projects to give me something I could shove down into a breadboard connector or into the Arduino connectors. Red is 5V, blue is ground. White is data and green is clock (I think, but see the code).

So, here’s my modest modification of the example code, in which I modify the ColorWipe function to first turn off any previously-lit lights before lighting up a new light with the given color. It’s a bit lazy, having a fencepost error on each end of the strand, trying to turn off (eg, set to black) the light number -1 and failing to turn off the last light in the strand. I’ve come to think of that as the “last color used indicator” feature.


--- libraries/WS2801/examples/strandtest/strandtest.pde 2011-12-13 00:43:49.000000000 -0500
+++ strandshort.ino 2012-11-24 17:29:53.829648206 -0500
@@ -16,7 +16,7 @@

// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
-WS2801 strip = WS2801(25, dataPin, clockPin);
+WS2801 strip = WS2801(50, dataPin, clockPin);

// Optional: leave off pin numbers to use hardware SPI
// (pinout is then specific to each board and can’t be changed)
@@ -37,8 +37,9 @@
colorWipe(Color(255, 0, 0), 50);
colorWipe(Color(0, 255, 0), 50);
colorWipe(Color(0, 0, 255), 50);
- rainbow(20);
+/* rainbow(20);
rainbowCycle(20);
+*/
}

void rainbow(uint8_t wait) {
@@ -75,8 +76,13 @@
// good for testing purposes
void colorWipe(uint32_t c, uint8_t wait) {
int i;
+ int j;
+ uint32_t black;
+ black = Color(0,0,0);

for (i=0; i < strip.numPixels(); i++) {
+ j=i-1;
+ strip.setPixelColor(j,black);
strip.setPixelColor(i, c);
strip.show();
delay(wait);

from on November 26th, 2012Comments0 Comments


Leave a Reply


  • × 2 = 4

blinky lights test

About a year ago, Interlock members were offered to go in on two group purchases, coordinated through the mailing list. The first was for Freeduino kits, with the boards pre-populated with the USB controller chip and mini-B socket. The second was for strands of individually-addressable RGB LEDs which can be controlled with an Arduino using this
Adafruit WS2801 library.

I indulged in each, getting one Freeduino kit as a soldering-skills confidence-building project and to give me a second Arduino-compatible device in case I wanted to start do something possibly destructive of my “store-bought” name-brand Arduino. I also got a single 50-light strand of the LEDs.

Well, as it turns out, I didn’t solder together the Freeduino until a couple of months ago. But I started playing with the LEDs almost right away, demonstrating them at our open house in the spring. I haven’t done a whole lot with them, other than play around with the color space a little bit by having them display cyan, magenta, and yellow (eg, the combinations of the other two colors leaving out, respectively, red, green, and blue).

The main problem I had starting out was that I wasn’t quite ready yet to start messing with external DC power supplies capable of delivering more than the half-amp or so that a USB port can supply. Reportedly, each LED can draw up to 60 milliamps, so there was no way I could use the out-of-the-box example code from the library, which lights up all the lights in the strand.

I could have had it just light up a half-dozen or so of the lights, I suppose, but I wanted to try all the lights, just not at once. I soldered onto the end of each of the four wires a bit of lead clipped from through-hole parts for other soldering projects to give me something I could shove down into a breadboard connector or into the Arduino connectors. Red is 5V, blue is ground. White is data and green is clock (I think, but see the code).

So, here’s my modest modification of the example code, in which I modify the ColorWipe function to first turn off any previously-lit lights before lighting up a new light with the given color. It’s a bit lazy, having a fencepost error on each end of the strand, trying to turn off (eg, set to black) the light number -1 and failing to turn off the last light in the strand. I’ve come to think of that as the “last color used indicator” feature.


--- libraries/WS2801/examples/strandtest/strandtest.pde 2011-12-13 00:43:49.000000000 -0500
+++ strandshort.ino 2012-11-24 17:29:53.829648206 -0500
@@ -16,7 +16,7 @@

// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
-WS2801 strip = WS2801(25, dataPin, clockPin);
+WS2801 strip = WS2801(50, dataPin, clockPin);

// Optional: leave off pin numbers to use hardware SPI
// (pinout is then specific to each board and can’t be changed)
@@ -37,8 +37,9 @@
colorWipe(Color(255, 0, 0), 50);
colorWipe(Color(0, 255, 0), 50);
colorWipe(Color(0, 0, 255), 50);
- rainbow(20);
+/* rainbow(20);
rainbowCycle(20);
+*/
}

void rainbow(uint8_t wait) {
@@ -75,8 +76,13 @@
// good for testing purposes
void colorWipe(uint32_t c, uint8_t wait) {
int i;
+ int j;
+ uint32_t black;
+ black = Color(0,0,0);

for (i=0; i < strip.numPixels(); i++) {
+ j=i-1;
+ strip.setPixelColor(j,black);
strip.setPixelColor(i, c);
strip.show();
delay(wait);

from on November 26th, 2012Comments0 Comments


Leave a Reply


  • × 5 = 45