Hello, I have problem with timing. I´m programming something like chess stopwatch with 2 lines of time (1 for each player RF/GDP).
It´s working with mechanic connection PIN 6 and 3 to GND (just hold second end of wire in hand)...Look at attached picture with orange wire.
LCD is I2C with backlight.
I´m using slovak language, so, some variabes or declarations is in slovak.
Problem No. 1:
Look at attached picture with LCD display. Problem is, that seconds are counting to neverending number... I was trying to solve it but I´m lost Same problem is minutes and hours....
Problem No. 2:
I want to do something like START/STOP (PAUSE) button on CD players. Ideally, if I start RF player-->GDP will stop counting (e.g. 01:24:53) and if I start GDP player-->RF will stop and GDP continue counting (from last time 01:24:53).
In future this will works on RFID tags, but now, I need to solve this 2 problems.
First of all: please edit your first post and put code tags (the "</>"-button in the editor) around your code part.
I have difficulties to understand how you stopwatch should work. The chess timers I now work the way that if one side activates the timer, the other timer stops and this side runs and vice-versa. In your code both timers could run at the same time. Is that your intention?
To convert a millisecond into hours, minutes and seconds you can use the following template:
uint32_t milliseconds = 33422334; // or any other value
uint32_t seconds = (milliseconds / 1000) % 60;
uint32_t minutes = (milliseconds / 1000 / 60) % 60;
uint32_t hours = (milliseconds / 1000 / 60 / 60);
Thank a lot.
Now, scetch counting 1...2....3.....59....09...19..29......99....10....11...12...13... It´good but second character stay on "9" until counting count to 9 and higher...
Now, problem No.2... Yes, you´re right, I need solve It this way.
" The chess timers I now work the way that if one side activates the timer, the other timer stops and this side runs and vice-versa. In your code both timers could run at the same time. Is that your intention? "
Now, scetch counting 1...2....3.....59....09...19..29......99....10....11...12...13... It´good but second character stay on "9" until counting count to 9 and higher...
You should either clear the screen before each update or print the numbers in double digits:
To get the desired functional behavior, call the opposite EndTimer function inside the StartTime function. But then you should remove the lcd.clear() call from the EndTimer functions, I guess.
Problem No.1 is totally solved. Thank you pylon program of counting under 10 sec/min is after little modification fully function. I´ve just write simple "if.." code to void printTime and it´s working.
Here is that simple code
if (sekundyGDP<10){
lcd.print(" ");}
if (minutyGDP<10) {
lcd.print(" ");}
Please describe in more detail what problem no. 2 is. I thought that the last sentence of my last post describes how to solve what I think your problem is. If it doesn't you have to provide more details.
I want to do something like START/STOP (PAUSE) button on CD players. Ideally, if I start RF player-->GDP will stop counting (e.g. 01:24:53) and if I start GDP player-->RF will stop and GDP continue counting (from last time 01:24:53).
Your definition was more exactly...
I have difficulties to understand how you stopwatch should work. The chess timers I now work the way that if one side activates the timer, the other timer stops and this side runs and vice-versa. In your code both timers could run at the same time. Is that your intention?
I know, now its working 2 players at the same time. My vision of function:
power on- no player´s time run, LCD backlight turn on, LCD write initial message
switch to RF player (PIN6) ----> RF player´s time counting
switch to GDP player (PIN3) ----> RF player´s time stop (e.g. 00:03:18)---> GDP player´s time start counting
switch to RF player (PIN6)----> GDP player´s time stop and RF player´s time continue from last value (00:03:18)
power on- no player´s time run, LCD backlight turn on, LCD write initial message
switch to RF player (PIN6) ----> RF player´s time counting
switch to GDP player (PIN3) ----> RF player´s time stop (e.g. 00:03:18)---> GDP player´s time start counting
switch to RF player (PIN6)----> GDP player´s time stop and RF player´s time continue from last value (00:03:18)
Why don't you just implement that? You already have functions to start and stop each timer. Just act accordingly if one of the switches is activated. You just have to remove the lcd.clear() from the EndTimer functions as I wrote earlier.
Try that and post the resulting sketch. If it doesn't work, provide information about what didn't work as you expected it. We will try to help you then. We don't write the code for you.