My Minute() function is as followscode:
void#include Minute<LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7){;
int lcd_key = 0;
int First_Digitadc_key_in = 0;
#define btnRIGHT 0
#define btnUP 144
#define btnDOWN 329
#define btnLEFT 504
#define btnSELECT 741
#define btnNONE 5
int read_LCD_buttons()
{
adc_key_in = analogRead(0);
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
return btnNONE;
}
unsigned long minInterval = 60000UL; // Interval for minutes in milliseconds
unsigned long secInterval = 1000UL; // Interval for seconds in milliseconds
unsigned long prevMinMillis = 0UL; // Holds the timestamp of the last time Minute() was called
unsigned long prevSecMillis = 0UL; // Holds the timestamp of the last time Second() was called
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - prevMinMillis > minInterval)
{
prevMinMillis = currentMillis;
Minute();
}
if (currentMillis - prevSecMillis > secInterval)
{
prevSecMillis = currentMillis;
Second();
}
}
void Second(){
int First_Digit = 0;
int Second_Digit = 0;
for(Second_Digit; Second_Digit<10; Second_Digit++){
if(Second_Digit==10){
First_Digit = First_Digit + 1;
lcd.print(First_Digit);}
}
lcd.setCursor(30, 0);
lcd.print(First_Digit);
lcd.setCursor(41, 0);
lcd.print(Second_Digit);
delay(60000);
lcd.clear();
if(First_Digit==5 && Second_Digit==9){
First_Digit = First_Digit - 5;
Second_Digit = Second_Digit -10;
lcd.print(First_Digit);
}
if(Second_Digit==9){
First_Digit = First_Digit + 1;
lcd.print(First_Digit);
Second_Digit = Second_Digit - 10;
}
}
}
And my Second():
void SecondMinute(){
int First_Digit = 0;
int Second_Digit = 0;
for(Second_Digit; Second_Digit<10; Second_Digit++){
if(Second_Digit==10){
First_Digit = First_Digit + 1;
}lcd.print(First_Digit);
}
lcd.setCursor(03, 0);
lcd.print(First_Digit);
lcd.setCursor(14, 0);
lcd.print(Second_Digit);
delay(1000);
lcd.clear();
if(First_Digit==5 && Second_Digit==9){
First_Digit = First_Digit - 5;
Second_Digit = Second_Digit -10;
lcd.print(First_Digit);
}
if(Second_Digit==9){
First_Digit = First_Digit + 1;
lcd.print(First_Digit);
Second_Digit = Second_Digit - 10;
}
}
}
And the setup and loop are very simple:
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
Second();
Minute();
}
I know i can't use delay() and have no idea how to tackle this another way.