I did a little debugging, and the problem with your code is the
if ( (((i+s)%50)<5 || (c == 0)
line.
here's a brief output of a little debugging:
x:96 i:44 s:4 c:0
x:96 i:45 s:4 c:0
x:96 i:46 s:4 c:15
x:96 i:47 s:4 c:15
x:96 i:48 s:4 c:15
x:96 i:49 s:4 c:15
x:97 i:0 s:3 c:15
x:97 i:1 s:3 c:15
x:97 i:2 s:3 c:0
you see when i+s is less than 5, it lights the light. 0+3%50 =3, which is < 5.
I wouldn't brute force the whole string to zero almost all the time... it's probably just me, but I like only addressing the bulbs I'm changing.
I'd suggest going with two loops, one going one way, the other going the other way. my head still hurts trying to figure out your algorithm, but that's prolly just my head. ;)
thanks for this man and no, heck people's heads hurt just talking to me on a daily basis. There is what folks call, "tory speak". I start things mid thought, say things that make perfect sense to me but not quite to others
I'm learning so any feedback, assistance is mucho appreciated
Tory
It works! I finally got my lights, some molex connectors, wired everything up, and now I'm golden.Good thing I'm going on vacation soon, because now the fun really starts. Thanks to everyone who's contributed, especially the brave souls who tried out my code and got it running properly.
First of all the string of 50 lights would be 151 channels(light number 63). You could make channel 152, 153, 154 be a command to all lights in a string. I thought that the software(vixen) could be controlling 154 channels for each string of lights. It would be possible to ignore 151 channels and just use the 152,153,154 channels to program the whole strand.
There would be a board say rgb controller board with two RJ45 one for input and one for output to the next board. Maybe power for the strand of lights, and a way to convert the signals from the RJ45 to control the lights in hardware and programmed chips(large task here). The board would need to use 160 channels so that it's div by 8. You may want to instead of using 151-154 for global commands use 157-160 for global commands.
This sounds okay for one strand but if you wanted to control 5,10,... strands it would require a lot of channels. Vixen at 57600 baud rate at 50 ms is limited to 286 and just two strands of light would be 308.
Last edited by holtzj; 12-23-2010 at 01:05 AM. Reason: Wrong original quote
somewhat, but I'm trying to make it more of a cylon light, where it's bright, and fading, as the thing scans, instead of fading in and out, by making the array start at 15 and count down, but the way he's using the array, it causes it to fade in in one direction, and fade out when the lights reverse.
change the array to 15, 13, 11, 9, 7, 5, 4, 3, 2, 1 and you'll see what I mean...
too late tonight to wrap my head around his logic and figure out where to tweak it....
I like it though.
I have not tested this code, but it should give good results. It is based on the code above. Give it a try.
It should chase forward then back repeatedly, all the while changing color from red to green to blue back to red etc...Code://added consts //const int defaultIntensity = 187; //0 to 255, duplicate definition const int minColor = 0; //Leave alone const int maxColor = 47; //256 * 3 -1; //Leave alone const int colorStep = 1; //1 to maxcolor const int minBulb = 0; //Bulb index of min bulb const int maxBulb = 49; //Bulb index of max bulb const int chaseLength = 5; //maxBulb + 1 //1 to max num bulbs const int defaultStepDirection = 1; //1 to maxBulb-1 //replace loop code with this void loop() { int currentColor = minColor; //minColor to maxColor int currentBulb = minBulb; //minBulb to maxBulb-1 int currentStepDirection = defaultStepDirection; //Leave alone while (true) { if (currentBulb > maxBulb + chaseLength) { currentStepDirection = -defaultStepDirection; currentBulb = maxBulb; } if (currentBulb < minBulb - chaseLength) { currentStepDirection = defaultStepDirection; currentBulb = minBulb; } setBulb(currentBulb, WheelRGB(currentColor)); setBulb(currentBulb - (chaseLength * currentStepDirection), bulbColor(0, 0, 0)); currentBulb += currentStepDirection; delay(75); if ((currentBulb >= minBulb) && (currentBulb <= maxBulb)) { currentColor += colorStep; } if (currentColor >= maxColor) { currentColor = minColor; } } } //replace the setBulb function with this one void setBulb(int bulb, int color) { if ((bulb < minBulb) || (bulb > maxBulb)) return; setBulb(bulb, defaultIntensity, color); } //add this function int WheelRGB(int WheelPosition) { if ((WheelPosition < 0) || (WheelPosition > maxColor)) return 0; if (WheelPosition < 16)//Red to Green { return bulbColor(15 - WheelPosition, WheelPosition, 0); } if (WheelPosition < 32)//Green to Blue { WheelPosition = WheelPosition - 16; return bulbColor(0, 15 - WheelPosition, WheelPosition); } if (WheelPosition < 48)//Blue to red { WheelPosition = WheelPosition - 32; return bulbColor(WheelPosition, 0, 15 - WheelPosition); } return 0; }
I don't have the lights yet, and I haven't complied the code, but you should be able to without too much problem, I hope. I did this just for fun, BTW.
Regards,
Clif
Last edited by CougerAC; 12-24-2010 at 03:07 PM. Reason: changed scaling for colors from 0-255 to 0-15
redefinition of defaultIntensity, using Delay instead of delay, just 'while' not 'do while' (why have an endless while loop inside of the loop() function?)...
those things fixed, it's working, mostly, but, it leaves a light on here and there, seemingly at random, as it goes back and forth, plus, the colors aren't what you said you intended, they vary, but are pale cyan's, magenta's occasionally yellow, light green, somewhat inconsistent..
cool otherwise! programming project grade: b ;)
Has anyone tried these with the snowflake, Santa, or snowman figures of these lights. Saw them at Lowe's and they have the same pattern. I'm betting they are the same, but curious if anyone has checked yet.
Erik
Bookmarks