Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time stop at 15sec #8

Open
fofito13 opened this issue Mar 1, 2016 · 13 comments
Open

time stop at 15sec #8

fofito13 opened this issue Mar 1, 2016 · 13 comments

Comments

@fofito13
Copy link

fofito13 commented Mar 1, 2016

i use this script in arduino nano:
`#include<CountUpDownTimer.h>
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!!

@AndrewMascolo
Copy link
Owner

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 [email protected] 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.

@fofito13
Copy link
Author

fofito13 commented Mar 2, 2016

It works right!!
Thank you very much for the reply and the fabulous library

@MeisterMax
Copy link

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 :)

@AndrewMascolo
Copy link
Owner

The answer is in the other comments

Sent from my iPhone

On Mar 13, 2016, at 10:39 AM, MeisterMax [email protected] 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.

@MeisterMax
Copy link

Am I blind? Which other comments? I only see five including the one I'm writing right now... sorry...

@AndrewMascolo
Copy link
Owner

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 [email protected] 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.

@MeisterMax
Copy link

Wow, thank you! It works. And, as fofito13 has already said, awesome library.
Max

@AndrewMascolo
Copy link
Owner

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 [email protected] 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.

@MiroHlad
Copy link

MiroHlad commented May 26, 2016

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

@AndrewMascolo
Copy link
Owner

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 [email protected] 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.

@MiroHlad
Copy link

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)");
}

@AndrewMascolo
Copy link
Owner

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 [email protected] 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.

@MiroHlad
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants