carlynorama

the blog

HL1606 Digital Manual Control

by Carlyn Maw on August 19, 2009, one comment

So because I like to go simple and low level first I wrote code with Xanders library that would step through an array of colors every time you press a button.
 
The main loop is some single button debounce code (Limor’s from Arduino.cc) and this:  

if (pressFlag) {      nextColor = colorArray[i];      mystrip.pushCmd(nextColor);      mystrip.latch();      i++; } if (i >= 9) {      i = 0; }
 
Which basically means “every time the button gets pushed get the next item in the 10 item array and send it as a command byte to the LED strip.” Because the latch is only thrown when the button is pressed it requires a button press for the colored lights to march on up the strip. I wrote this code to make sure I knew how the the bytes were flowing out and what they were doing to the LEDs because I was having some trouble with the original “doColor” function.
 
The byte array I wrote looks like this:
 
 colorArray[0] = B10000001;  colorArray[1] = B10000101;  colorArray[2] = B10000100;  colorArray[3] = B10010100;  colorArray[4] = B10010000;  colorArray[5] = B10010101;  colorArray[6] = B10010001;  colorArray[7] = B10000000;  colorArray[8] = B10001010;  colorArray[9] = B10100010;
 
It looks a lot some colors we saw in John Cohn’s Pixaxe code… The important thing to remember when looking at these numbers is that the bit furthest to the right is the one that gets send first, so when it is 1 the red LED is on. The command byte is explained in the Synoptic Labs library, but keep in mind it is explained as LEFT -> RIGHT, so the INVERSE of what you might think you’re seeing here. I’ve added a couple of graphics to show the current set up and how it works. I’ll make another video when the results are more exciting.
 
I’m attaching the code as a compressed file so it won’t get displayed in its entirety.

 

One thought on “HL1606 Digital Manual Control

  1. I’m trying to use the HL1606 strip PWM library with the HL1606 strip (I got it from http://www.ledlightinghut.com/digital-addressable-hl1606-ic-rgb-led-light-strip.html ) and it isn’t working. Well, it loads on the 32u4 fine, but the displayed "colorswirl" example is not as intended: everything looks bluish-whitish-purple instead of the more primary colors that are expected. Other examples and test code I write all looks the same. Fiddling with setSPIdivider() and setCPUmax() doesn’t help. I’ve even tried tweaking the SPI settings in the PWM library (data order, clock phase, etc.) to no avail.

Leave a Reply to Ryan Hansen Cancel reply

carlynorama is Stephen Fry proof thanks to caching by WP Super Cache