Hello
I'm having problems with a simple portion of my program. I've extracted this section into it's own program and simplified it to debug but I'm still stumped.
The idea of the program is to make a ring of 12 led's loop round, however the loop stops after a random period of time and I can't understand why
#include "Tlc5940.h"
//Alarm Rules
int alarmAnimationDelay = 52;
int alarmAnimationTime = 0;
void setup() {
//Initialise the tlc driver
Tlc.init();
Tlc.set(0,500);
Tlc.set(1,400);
Tlc.set(2,300);
Tlc.set(3,200);
Tlc.set(4,100);
Tlc.set(5,0);
Tlc.set(6,0);
Tlc.set(7,0);
Tlc.set(8,0);
Tlc.set(9,0);
Tlc.set(10,50);
Tlc.set(11,100);
Tlc.update();
alarmAnimationTime = millis();
}
void loop(){
if(millis() - alarmAnimationTime == alarmAnimationDelay){
int alarmAnimation0 = Tlc.get(0);
int alarmAnimation1 = Tlc.get(1);
int alarmAnimation2 = Tlc.get(2);
int alarmAnimation3 = Tlc.get(3);
int alarmAnimation4 = Tlc.get(4);
int alarmAnimation5 = Tlc.get(5);
int alarmAnimation6 = Tlc.get(6);
int alarmAnimation7 = Tlc.get(7);
int alarmAnimation8 = Tlc.get(8);
int alarmAnimation9 = Tlc.get(9);
int alarmAnimation10 = Tlc.get(10);
int alarmAnimation11 = Tlc.get(11);
Tlc.set(0,alarmAnimation1);
Tlc.set(1,alarmAnimation2);
Tlc.set(2,alarmAnimation3);
Tlc.set(3,alarmAnimation4);
Tlc.set(4,alarmAnimation5);
Tlc.set(5,alarmAnimation6);
Tlc.set(6,alarmAnimation7);
Tlc.set(7,alarmAnimation8);
Tlc.set(8,alarmAnimation9);
Tlc.set(9,alarmAnimation10);
Tlc.set(10,alarmAnimation11);
Tlc.set(11,alarmAnimation0);
Tlc.update();
alarmAnimationTime = millis();
}
}
Here's the strange bit, if you adjust the animationDelay variable it changes the point at which the loop stops working. So for example, at 52, the code always stops at the same point, at 51, the code stops at a different point to 52, but always at the same point.
Can anyone explain why?
I've managed to work out at 50, the code loops 28 times (1400 milliseconds) every time.
Help!!!
Thank you