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