Int repeat = 0 // How many times should we loop before stopping? (0 for no stop) Int loopCount = 60 // How often should DEBUG report? Int DEBUG = 0 // DEBUG counter if set to 1, will write values back via serial Int hold = 0 // Optional hold when a color is complete, before the next crossFade Int bluVal = black int wait = 3 // 10ms internal crossFade delay increase for slower fades Int bluPin = 11 // Blue LED, connected to digital pin 11// Color arrays Int redPin = 10 // Red LED, connected to digital pin 9 Int grnPin = 9 // Green LED, connected to digital pin 10 * are a little fussy - the inner workings are explained * The internals of the program aren't complicated, but they Set the DEBUG flag to 1 if you want debugging output to be * program for 'hold' milliseconds when a color is complete, There is an optional 'hold' variable, which pasues the * and make the last color black if you want it to fade out at the end.) * then stop on the last color in the sequence. * if it is set to a number, it will loop that number of times, If 'repeat' is set to 0, the program will loop indefinitely. * practice, the other functions the code is performing slow this * a 'wait' of 10 ms should make a crossFade of ~10 seconds. * sets the approximate duration of a single crossfade. The internal loop runs for 1020 interations the 'wait' variable * you can set the initial color to be any other color The initial color is set to black (so the first color fades in), but * In addition, there are 5 optional settings you can adjust: * Those colors will appear in that order, fading out of * In the main part of the program, you need to list the order * Some common colors are provided below, or make your own * Red is the red LED at full, blue and green off * controlling the red, green and blue LEDs * A color is just an array of three percentages, 0-100, Describe the colors you want to be displayed * To create fades, you need to do two things: ** Code for cross-fading 3 LEDs, red, green and blue (RGB) I ended up using a slow crossfade demo as the base for the tree. Feel free to use a cheapie inline preprogrammed controller like I did on my umbrella instead. I had plenty of these boards left over from other lamp projects. Just had to switch the target programmer and program the chip directly. I could have used an arduino uno and did to make the initial tests using an RGB shield but ended up using a custom single board with a bare Atmega328 chip. This also means a controller will be needed. This means I can have a programmed effect but all leds change color simultaneously.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |