We are about to switch to a new forum software. Until then we have removed the registration on this forum.
This is "my" code (credits goes to @Chrisis. He created similiar timer here: So its more his code then mine.
What I want:
1.) When key "T" is pressed timer starts to run (I did this).
2.) When the timer comes to 45:00, timer stops.
3.) When key "T" is pressed again, timer starts where it stoped.
So with key T I want to start and stop the timer, and when timer comes to 45:00 to automaticlly stop at this time until key "T" is pressed again to continue counting.
Answers
2.) goes back to zero and starts?
Sorry, but this is more of a stopwatch to measure a time elapsed and not a timer
But I can have a look later
I don't want to go back to zero. I need this timer for a football purposes. So when the timer comes to 45:00, timer stops and then when I press key T timer goes on from 45:00.
Like that:
44:56
44:57
44:58
44:59
45:00 (at this time Timer stops autamaticlly)
When key "T" is pressed timer goes on
45:01
45:02
45:03
...
till 90 then 0
till 90 yes, then it's over. :)>-
do you mean 45 Minutes or seconds ?
Few post to explore here:
https://forum.processing.org/two/search?Search=stopwatch
More sparse post of interest:
https://forum.processing.org/two/search?Search=timer
Kf
it's for two times 4,5 seconds now
you need both times say 4500 (NOT 9000)
Thank you Chrisis. I'll look later in more detail and I'll ask you some questions too.
If I move this two lines of code
from void setup() to void keyPressed() under an if keyCode 10 (Enter key) statment it's not working properly. Why? I don't get it.
Let's say I want to start timer when I press Enter key and not when I run Sketch. This should work but doesn't and I don't understand why not. :(
It's because we use millis and millis counts from start of the sketch and not from moment you pressed Enter
It took me ages to figure that out for the 2nd half of the match (where a similar problem occurs)
Just set up a var and when enter is pressed read the current millis in it.
Then use the vars data to recalculate the results
(brief description for a potential harder problem)
I still have some problem with that. Code bellow works like that: When I press key "T" timer starts counting from zero. "S" key stops the timer and continue timer. When pressing key "h" displays text "halftime" and when pressing key "enter" displays text "fulltime".
What I want is this: If there is text halftime and I press button T, timer starts from 45:00.
I tried that like that, but without success. Only for a split second timer start from 45:00 but then goes back to 00:00
Wow, I would be surprised if no library already existed for all this - this is far too common a question for no one to have made one.
P.S. Pls tell me if no such library exists. I have one and will upload it.
Yeah, please post it!
Ok. So I guess no one has made any library like it before. Also note that this is not a library to trigger time based events (though it may not be too difficult to add such functionality).
Probably in two days time. It will (obviously) take longer to provide a complete documentation, but the library will be on GitHub with examples before the weekend.
Thank you!
Seriously @Lord_of_the_Galaxy? You really do not need to do this just for my example. I feel guilty right now. :( You guys are so unbelivable helpfull here that scares me ^:)^
Edit: My horrible english tho :))
@Lord_of_the_Galaxy -- it is true that stopwatch timers are a common question -- looking forward to seeing what you come up with!
While I haven't used them, the two timing-related libraries that I'm aware of in Processing Contributions (Utilities) are CountdownTimer by Dong Hyun Choi and TimedEvents by Jason Gessner -- it might be interesting to look at them for reference / comparison.
Uploaded on Github - Timing Utilities.
^:)^ ^:)^ ^:)^ Thank you very much Sir! ^:)^ ^:)^ ^:)^
I still don't know how to get it on the Processing website. Trying to find out now. Will let you know then.