Open fofito13 opened 8 years ago
The answer is among the other comments. It's a line of code you need to fix.
Sent from my iPhone
On Mar 1, 2016, at 7:36 AM, fofito13 notifications@github.com wrote:
i use this script: `#include
CountUpDownTimer T(DOWN); const int botonPin1 = 5; int estadoBoton1 = 0; bool estado = 1;
void setup() { Serial.begin(9600); //pinMode(6, INPUT_PULLUP); pinMode(botonPin1, INPUT); T.SetTimer(0,0,20); T.StartTimer(); Serial.println("inicio \r\n"); }
void loop() { T.Timer(); // run the timer
//Serial.println("run \r\n"); if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. { Serial.print(T.ShowHours()); Serial.print(":"); Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.println(T.ShowSeconds()); }
}`
at 15 seconds the counter stop. please help me!!
— Reply to this email directly or view it on GitHub.
It works right!! Thank you very much for the reply and the fabulous library
Hmmm... I've just the same problem. My timer stops at 15 seconds, no matter whether it is 2:15, 5:15 or 0:15. Moreover, if I set the timer to, say, 0:14, it doesn't even start to count down. I don't quite get though what the solution is... what other comment are you refering to? Thanks in advance, Max
Here's my code, by the way:
CountUpDownTimer T(DOWN); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2); T.SetTimer(0, 2, 45); T.StartTimer();
}
void loop() {
T.Timer();
lcd.setCursor(0, 0); lcd.print(T.ShowSeconds()); lcd.setCursor(0, 1); lcd.print(T.ShowMinutes());
}
Rather straightforward, I'd have thought... But probably I'm just too stupid :)
The answer is in the other comments
Sent from my iPhone
On Mar 13, 2016, at 10:39 AM, MeisterMax notifications@github.com wrote:
Hmmm... I've just the same problem. My timer stops at 15 seconds, no matter whether it is 2:15, 5:15 or 0:15. Moreover, if I set the timer to, say, 0:14, it doesn't even start to count down. I don't quite get though what the solution is... what other comment are you refering to? Thanks in advance, Max
Here's my code, by the way:
include "CountUpDownTimer.h"
include "LiquidCrystal.h"
CountUpDownTimer T(DOWN); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2); T.SetTimer(0, 2, 45); T.StartTimer();
}
void loop() {
T.Timer();
lcd.setCursor(0, 0); lcd.print(T.ShowSeconds()); lcd.setCursor(0, 1); lcd.print(T.ShowMinutes());
}
Rather straightforward, I'd have thought... But probably I'm just too stupid :)
— Reply to this email directly or view it on GitHub.
Am I blind? Which other comments? I only see five including the one I'm writing right now... sorry...
Sorry about that. I found the issue and I will post the fix soon. The problem was a missing operator ( ! ) in the TimeCheck function. All you need to do is change _type to !_type. Save it and it should work.
Sent from my iPhone
On Mar 13, 2016, at 1:44 PM, MeisterMax notifications@github.com wrote:
Am I blind? Which other comments? I only see five including the one I'm writing right now... sorry...
— Reply to this email directly or view it on GitHub.
Wow, thank you! It works. And, as fofito13 has already said, awesome library. Max
Thank you. I fixed the bug in the library and re-uploaded it
Sent from my iPhone
On Mar 13, 2016, at 5:05 PM, MeisterMax notifications@github.com wrote:
Wow, thank you! It works. And, as fofito13 has already said, awesome library. Max
— Reply to this email directly or view it on GitHub.
Hi
if TimeCheck() should return True if the time is equal to particular time
The code should be updated as follows:
if(_type)
return (Clock == TC);
else
return (Clock == TC );
}
I tested and It works good to me.
Thanks
Miro
What happens if you are doing something (or decide to put in a delay) and go past the time you set for? Then == doesn't work.
Sent from my iPhone
On May 26, 2016, at 6:41 PM, MiroHlad notifications@github.com wrote:
Hi if TimeCheck() should returns true if the time is equal to particular time shouldn't be the code like that if(_type) return (Clock == TC); else
return (Clock == TC ); } It works good to me. Thanks Miro
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Hi agree with you that for delays is == unusable. I need to check the time a lot of times, but when I used <= . It returns True on a first check and than keep the True, if I do next check I always receive 1. Maybe I just dont understand the timecheck function and I should use it different way. When I changed the logic to == it works as I need. I simplified the example how I use it - see below - in my script I dont use the exact time values in check function but variables,
Anyway I like your library, It makes my life easier. :) THANK YOU
if (T.TimeCheck(0, 0, 27)) {
turnLR = 1;
// Serial.println(T.TimeCheck(0, 0, 27));
}
else if (T.TimeCheck(0, 0, 20)) {
turnLR = 0;
// Serial.println("TimeCheck(0, 0, 20)");
}
else if (T.TimeCheck(0, 0, 15)) {
turnLR = 2;
// Serial.println("TimeCheck(0, 0, 15)");
}
else if (T.TimeCheck(0, 0, 5)) {
turnLR = 0;
// Serial.println("TimeCheck(0, 0, 5)");
}
Do a print of TimeCheck at those times and see if you always see true.
I'm betting if you invert the logic i.e. If( !T.TimeCheck(0,0,27)) If (!T.TimeCheck(0,0,20)) . . .
You should see the code working.
Or if you want you can create a new method for yourself and I will add it in later to the library.
I would call it "ExactTimeCheck(...)"
Sent from my iPhone
On May 27, 2016, at 3:24 PM, MiroHlad notifications@github.com wrote:
Hi agree with you that for delays is == unusable. I need to check the time a lot of times, but when I used <= . It returns True on a first check and than keep the True, if I do next check I always receive 1. Maybe I just dont understand the timecheck function and I should use it different way. When I changed the logic to == it works as I need. I simplified the example how I use it - see below - in my script I dont use the exact time values in check function but variables,
Anyway I like your library, It makes my life easier. :) THANK YOU
if (T.TimeCheck(0, 0, 27)) { turnLR = 1;
// Serial.println(T.TimeCheck(0, 0, 27)); } else if (T.TimeCheck(0, 0, 20)) { turnLR = 0; // Serial.println("TimeCheck(0, 0, 20)"); } else if (T.TimeCheck(0, 0, 15)) { turnLR = 2; // Serial.println("TimeCheck(0, 0, 15)"); } else if (T.TimeCheck(0, 0, 5)) { turnLR = 0; // Serial.println("TimeCheck(0, 0, 5)"); }
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Thank you for your fast respons and your time. Currently working on some project and it is close to end. I like the ExactTimeCheck(...), but I will give it a time till I finished it, to be sure that the right way. Thank you again. Miro
i use this script in arduino nano: `#include
CountUpDownTimer T(DOWN);
void setup() { Serial.begin(9600); //pinMode(6, INPUT_PULLUP); pinMode(botonPin1, INPUT); T.SetTimer(0,0,20); T.StartTimer(); }
void loop() { T.Timer(); // run the timer
//Serial.println("run \r\n"); if (T.TimeHasChanged() ) // this prevents the time from being constantly shown. { Serial.print(T.ShowHours()); Serial.print(":"); Serial.print(T.ShowMinutes()); Serial.print(":"); Serial.println(T.ShowSeconds()); }
}`
at 15 seconds the counter stop. please help me!!