Page 1 of 1
Lighting test code question
Posted: Mon May 11, 2015 9:04 am
by joshlawless
Can you see a reason why this isn't setting "b" equal to 0 to 4095 and back to 0 by steps of 1? This test code won't work for me (although if I pass a value in the code, e.g., CustomExpansion(0x41, 0, 2048), it works fine).
Code: Select all
//global variable
int a = 0;
int b = 0;
void loop()
{
a = a++;
if (a<4096) {b = a;}
else {b = 8191 - a ;}
if (a==8192) {
a = 0;
b = 0;
}
CustomExpansion(0x41, 0, b);
}
Re: Lighting test code question
Posted: Mon May 11, 2015 10:49 am
by rimai
Did you change the code original post?
This code works.
The original one doesn't.
Re: Lighting test code question
Posted: Mon May 11, 2015 6:34 pm
by joshlawless
I did, but didn't think helped. I changed the "if (a=8192)" to "if (a==8192)", but didn't see any improvement. I think because it takes so long to iterate through one loop(), I couldn't tell that the intensity was increasing (changing the increment from 1 to 128 allows it to ramp each channel up and down much faster).
If I try to run the whole ramp up and ramp down inside of one loop() (e.g., with a for () loop), the controller crashes and gets stuck in a reboot loop. I gather there's some limit on how much can be accomplished in one iteration through the main loop. Can you recommend any good learning resources on the Arduino environment that would be helpful for learning this kind of thing?
Re: Lighting test code question
Posted: Mon May 11, 2015 7:39 pm
by rimai
Yes, we have a 1s watchdog timer setup.