Tuesday, August 18, 2009

HL1606 Digital Manual Control

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.

See and download the full gallery on posterous

Download now or preview on posterous
buttonMarch.txt (4 KB)

Posted via email from what2day's posterous

No comments: