Reseting the Clock and display it in the 1602 lcd

Hello there,

i cant find a way to display the Millis() reset, on the 1602 lcd.
I know there is not really a reset.

Here are the last 3 ways i tried. Its maybe 1-2 months old, so i cant remember that good what was going on there.

I need to let the Arduino count after a HIGH. Let it count the seconds, minutes and hours, till the LOW. After the input "LOW" the Counter need to be reset, for the next HIGH.

I now ordered a real time clock to try it with it.

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int Fotozelle = 7;
int FotozelleState = 0;

int interval = 1000;
unsigned long previousmillis = 0;

void setup() {

Serial.begin(19200);
pinMode(Fotozelle, INPUT);

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Now : ");

lcd.setCursor(0, 1);
lcd.print("Total: ");

lcd.setCursor(8, 0);
lcd.print("00:00:00");

}

void loop() {

FotozelleState = digitalRead(Fotozelle);
if(FotozelleState == LOW)
{
lcd.setCursor(14, 0);
lcd.print(millis() / 1000);
}
else
{
unsigned long currentmillis = millis();
if ((unsigned long)(currentmillis - previousmillis) >= interval)
{
unsigned long previousemillis = currentmillis;
}
}
FotozelleState = digitalRead(Fotozelle);
if(FotozelleState == HIGH)

delay(1500);
lcd.setCursor(14, 0);
lcd.print("00");
}


#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

long day = 86400000; // 86400000 milliseconds in a day
long hour = 3600000; // 3600000 milliseconds in an hour
long minute = 60000; // 60000 milliseconds in a minute
long second = 1000; // 1000 milliseconds in a second

const int Fotozelle = 7;

void setup() {

Serial.begin(57600);
pinMode(Fotozelle, INPUT);

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Now : ");

lcd.setCursor(0, 1);
lcd.print("Total: ");

lcd.setCursor(8, 0);
lcd.print("00:00:00");

}

void loop() {

time();
delay(1000);

}

void time(){

long timeNow = millis();

int days = timeNow / day;
int hours = (timeNow % day) / hour;
int minutes = ((timeNow % day) % hour) / minute;
int seconds = (((timeNow % day) % hour) % minute) / second;

digitalRead(Fotozelle);
if(Fotozelle == LOW)
{

lcd.setCursor(8, 0);
lcd.print(hours,DEC);
lcd.setCursor(11, 0);
lcd.print(minutes);
lcd.setCursor(14, 0);
lcd.print(seconds);
}
else{
digitalRead(Fotozelle);
if(Fotozelle == HIGH)
{
delay(1500);
lcd.setCursor(14, 0);
lcd.print("00:00:00");

}}}


#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

long day = 86400000; // 86400000 milliseconds in a day
long hour = 3600000; // 3600000 milliseconds in an hour
long minute = 60000; // 60000 milliseconds in a minute
long second = 1000; // 1000 milliseconds in a second

const int Fotozelle = 7;

void setup() {

Serial.begin(57600);
pinMode(Fotozelle, INPUT);

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Now : ");

lcd.setCursor(0, 1);
lcd.print("Total: ");

lcd.setCursor(8, 0);
lcd.print("00:00:00");

}

void loop() {

time();
delay(1000);

}

void time(){

long timeNow = millis();

int days = timeNow / day;
int hours = (timeNow % day) / hour;
int minutes = ((timeNow % day) % hour) / minute;
int seconds = (((timeNow % day) % hour) % minute) / second;

digitalRead(Fotozelle);
if(Fotozelle == LOW)
{

lcd.setCursor(8, 0);
lcd.print(hours,DEC);
lcd.setCursor(11, 0);
lcd.print(minutes);
lcd.setCursor(14, 0);
lcd.print(seconds);
}
else{
digitalRead(Fotozelle);
if(Fotozelle == HIGH)
{
delay(1500);
lcd.setCursor(14, 0);
lcd.print("00:00:00");

}}}

i cant find a way to display the Millis() reset,

What is a millis() reset ?
The millis() value increments every millisecond. Why do you want to reset it ?

I want to let the Arudino count in millis(). Because its more or less accurate. BUT the couting should start if there is an HIGH INPUT.
Now after a LOW it has to stop counting and then start all over again at 00:00:00, after another HIGH to count the seconds, minutes and hours.

I want to let the Arudino count in millis()

Frankly, you will have a job stopping it

after a LOW it has to stop counting and then start all over again at 00:00:00,

Don't try to reset millis() when that happens. Just save the value of millis() at that time and make subsequent time measurements relative to that value

You can use a library such as the Time library without an RTC, that way you can get the code working, and once you have the RTC just add the instructions to sync to the RTC.

UKHeliBob:
Don't try to reset millis() when that happens. Just save the value of millis() at that time and make subsequent time measurements relative to that value

Yes I like that. How can i save the value? I would love to save the Value in the second Row and display it.

How can i save the value?

Take a look at the BlinkWithoutDelay example to see how millis() timing is done by saving the millis() value when an event occurs then comparing the saved value with the current value to ascertain whether the required period has elapsed

For more details see Using millis() for timing. A beginners guide