This answer targets your example using millis(). StartMillis = currentMillis //IMPORTANT to save the start time of the current LED state. ![]() ![]() If (currentMillis - startMillis >= period) //test whether the period has elapsed Unsigned long startMillis //some global variables available anywhere in the programĬonst unsigned long period = 1000 //the value is a number of millisecondsĬurrentMillis = millis() //get the current "time" (actually the number of milliseconds since the program started) Here is the code I used with millis() and gave me around 12min difference. Any help with this problem or any additional information i am missing which will be useful or any other solution other than using timer2 interrupt will be appreciated. Doesn't that mean Timer2 has a higher priority? My ultimate goal is to do the one-hour countdown. But is timer1 interrupts priority is higher than timer2? But according to the ATmega328p datasheet, the vector no. In ledP10.cpp there is a callback method for timer1 and it contains loops and may line of code. My guess, it's happening because of the TimerOne library but I couldn't find the solution. When I use only MsTimer2 library the results are something like this. In the interrupt routine, I am printing millis() to see at after how many ms the interrupt occurs. myled.showmsg_single_scroll("this is single led test",2,8,0) Myled.showmsg_single_static((char*)time_buff, 0) Volatile bool xIsInterruptOcuured = false Uint8_t minute = 0, second = 0, hour = 1 But now suddenly my MsTimer2 doesn't generate pure 1sec. Now what I did is the added both the library in my project and I am doing the countdown. When I individually run both of the libraries, my scrolling on the display is perfect and my timer library also generates a pure 1sec interrupt. So for countdown i am using MsTimer2 library which usese timer2 of arduino. P10_LED and I need to display the one-hour countdown on the display module. ![]() Everyone, I am using, P10 Dot Matrix Display with Arduino Uno.
0 Comments
Leave a Reply. |