I'm creating a project using 7-segment displays and the max7219. To test the 7219, which I've never used before, I wrote a simple program to increment a number and output to the display every 20ms. My problem is that at 800 the program stops. Any ideas on why this happens? It doesn't matter if I start at zero or 500 or 750, it always stops after 800. Here's the code and a link to the video.
#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1);
int delayTime = 20;
int tick = 500;
void setup(){
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}
void loop(){
int thousands, hundreds, tens, ones;
thousands = tick/1000;
hundreds = tick/100;
hundreds = hundreds - ((hundreds/10)*10);
tens = tick/10;
tens = tens - ((tens/10)*10);
ones = tick - ((tick/10)*10);
if(tick >= 1000){
lc.setDigit(0,3,thousands,true);
}
if(tick >= 100){
lc.setDigit(0,2,hundreds,true);
}
if(tick >= 10){
lc.setDigit(0,1,tens,true);
}
lc.setDigit(0,0,ones,true);
tick++;
delay(delayTime);
}