Hi,
i want to make timecode led display that run by itself (without external clock or timecode signal)
its fixed framerate (in the arduino code),
i found good simple code that made by dan thomson based on the stopwatch (Dan Thompson: Timecode Based Stopwatch),
in the original code dan used lcd display,
so i tried to convert the code to work with 7 segment 8 digit display (using the MAX7219, "LedControl.h" library)
the code compiled successfully without errors, but the display itself not running well,
only the two first frame digits (FPS) running well,
but the other digits dose not showing the numbers (the digits flickering fast and i cant see the numbers).
due to message length limitation, i can't post the full code,
so i add the lines i have problem with, and i attach the sketch file:
/////////////////////////////////////////////
// Routine to report elapsed time
/////////////////////////////////////////////
elapsedTime = millis() - startTime; // store elapsed time
elapsedMinutes = (elapsedTime / 60000L);
elapsedSeconds = (elapsedTime / 1000L); // divide by 1000 to convert to seconds - then cast to an int to print
elapsedFrames = (elapsedTime / interval); // divide by 40 to convert to 1/25 of a second - then cast to an int to print
fractional = (int)(elapsedFrames % frameRate); // use modulo operator to get fractional part of 25 Frames
fractionalSecs = (int)(elapsedSeconds % 60L); // use modulo operator to get fractional part of 60 Seconds
fractionalMins = (int)(elapsedMinutes % 60L); // use modulo operator to get fractional part of 60 Minutes
lc.clearDisplay(0); //and clear the display
if (fractionalMins < 10){ // pad in leading zeros
digitFive = 0; // add a zero
}
if (fractionalMins > 9){
float fractionalMinsresult = fractionalMins / 10; //s/b 4.2 fractionalMinsResulting in 4
digitFive = fractionalMins % 10; //this gets the remainder of 42/10 or 2
digitSix = fractionalMinsresult;
}
else
{
digitFive = fractionalMins;
digitSix = 0;
}
if (fractionalSecs < 10){ // pad in leading zeros
digitThree = 0; // add a zero
}
if (fractionalSecs > 9){
float fractionalSecsresult = fractionalSecs / 10; //s/b 4.2 fractionalSecsResulting in 4
digitThree = fractionalSecs % 10; //this gets the remainder of 42/10 or 2
digitFour = fractionalSecsresult;
}
else
{
digitThree = fractionalSecs;
digitFour = 0;
}
if (fractional < 10){ // pad in leading zeros
digitOne = 0; // add a zero
}
if (fractional > 9){
float fractionalresult = fractional / 10; //s/b 4.2 fractionalResulting in 4
digitOne = fractional % 10; //this gets the remainder of 42/10 or 2
digitTwo = fractionalresult;
}
else
{
digitOne = fractional % 10;
digitTwo = 0;
}
}
else{
lastButtonState = buttonState; // store buttonState in lastButtonState, to compare next time
}
can you please tell me what i did wrong? :~
timecode_prototype2.ino (9.92 KB)