8806 LED Strip Programming
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 3
- Joined: Thu Jan 31, 2013 4:41 pm
8806 LED Strip Programming
I'm about 1 level up from noob when it comes to Arduino programming. I've been working for several hours trying to dissect the example files in the 8806 library. I'm wanting to just get down to lighting the entire strip in 1 color and then figuring out how to light an individual LED a certain color. This will eventually lead to further projects, but just getting the understanding of how to break down the programming. Any help would be great. Thanks.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 8806 LED Strip Programming
There are three functions you'll use most often:
.Color(), which takes R, G, B values and packs them up in a form the LPD8806 can understand.
.setPixelColor(), which gives each pixel its own address, and is the main LED programming interface. It takes a pixel number and a Color value from the function above as arguments.
.show(), which actually sends all the data to the strip.
To set a single pixel call:
assuming you've named your LPD8806 object 'strip' and all the other variables contain numbers that work in context.. 'n' will be the number of a pixel that exists in the strip, and 'r, g, b' will each be between 0 and 255.
To set the whole strip to the same color, just do the same thing for every value of 'n' that would be valid for the strip you're trying to control.
Remember to call:
To send the changes out to the actual LPD8806 chips.
.Color(), which takes R, G, B values and packs them up in a form the LPD8806 can understand.
.setPixelColor(), which gives each pixel its own address, and is the main LED programming interface. It takes a pixel number and a Color value from the function above as arguments.
.show(), which actually sends all the data to the strip.
To set a single pixel call:
Code: Select all
strip.setPixelColor( n, strip.Color( r, g, b ) );
To set the whole strip to the same color, just do the same thing for every value of 'n' that would be valid for the strip you're trying to control.
Remember to call:
Code: Select all
strip.show();
-
- Posts: 3
- Joined: Thu Jan 31, 2013 4:41 pm
Re: 8806 LED Strip Programming
This is ugly programming, but I'm still getting results that aren't what I'm wanting. With this program
http://BANNED.com/TcTFtsvX
I have White for the first 22 LEDs, then a red, followed by random colors thorughout the rest of the strip. Thanks if somebody could see what I'm doing. I know there has to be an easier way to set the LED number but since I'm doing it before the loop. In the loop they flashed.
Thanks.
http://BANNED.com/TcTFtsvX
I have White for the first 22 LEDs, then a red, followed by random colors thorughout the rest of the strip. Thanks if somebody could see what I'm doing. I know there has to be an easier way to set the LED number but since I'm doing it before the loop. In the loop they flashed.
Thanks.
-
- Posts: 3
- Joined: Thu Jan 31, 2013 4:41 pm
Re: 8806 LED Strip Programming
Think I found it, had to go back to hardware SPI and everything started working.
Please be positive and constructive with your questions and comments.