Open Vatch opened 2 years ago
Couldn't find anything obviously wrong in your code. I could guess it has small chance that somehow using interrupt and blocking them with cli() and sei() might interface with LCD communication if it's interrupted while sending data. But if it always happens after 2 hours it might not be it In a mean time I would suggest printing what variables are sent to the screen (if you haven't done so) and checking are they really valid:
if (time_left <= 0) {
tm.display(0, 20);
tm.display(1, 20);
tm.point(0);
tm.display(2, 20);
tm.display(3, 20);
Serial.println("Display time <= 0");
Serial.println(time_left);
} else {
tm.display(0, tensOfMin_left);
tm.display(1, Min_left);
tm.point(1);
tm.display(2, tensOfSec_left);
tm.display(3, Sec_left);
Serial.println("Display time > 0");
Serial.println(tensOfMin_left);
Serial.println(Min_left);
Serial.println(tensOfSec_left);
Serial.println(Sec_left);
}
P.S code is formated by putting it between ``` Your Code Here ```
Couldn't find anything obviously wrong in your code. I could guess it has small chance that somehow using interrupt and blocking them with cli() and sei() might interface with LCD communication if it's interrupted while sending data. But if it always happens after 2 hours it might not be it In a mean time I would suggest printing what variables are sent to the screen (if you haven't done so) and checking are they really valid:
if (time_left <= 0) { tm.display(0, 20); tm.display(1, 20); tm.point(0); tm.display(2, 20); tm.display(3, 20); Serial.println("Display time <= 0"); Serial.println(time_left); } else { tm.display(0, tensOfMin_left); tm.display(1, Min_left); tm.point(1); tm.display(2, tensOfSec_left); tm.display(3, Sec_left); Serial.println("Display time > 0"); Serial.println(tensOfMin_left); Serial.println(Min_left); Serial.println(tensOfSec_left); Serial.println(Sec_left); }
P.S code is formated by putting it between
Your Code Here
I printed the value of time_left but I haven't yet printed the values sent to the screen. Ill test it out. Also thanks for the advice on formatting the post! I was struggling trying to get it to work
The project: I am using a TM1637 7seg display as a count down timer for a coin operated module. Basically you put a quarter into a coin acceptor module, it sends a pulse to the Arduino, that adds a set amount of time to the counter and the time left on the counter is displayed on the TM1637 7seg display. So long as there is time left on the counter a relay is triggered that powers an external device. I am using TM1637.h "Grove 4-Digit Display" library from Seeed Studio to control the display.
The problem: Everything works as intended until I leave the Arduino running for 2 hours or so. After running for a while the TM1637 display will display the top segment lit on all 4 character positions when it should just leave them blank. Upon inserting a coin the timer and relay works as it should and when its done counting down the display returns to the aforementioned state. Hitting reset or cycling power fixes this and after running for a while the display repeats the behavior.
I am fairly certain I have narrowed the problem down to the library itself as I have monitored pretty much all variables to look for something that may be rolling over after extended periods of time and I haven't found any culprits.
Are there any variables in the TM1637.h library that would be rolling over and causing it to display these odd characters rather than just being blank like it is supposed to?
My code: