Hi everyone.
In this sample code I start counting down from 60 to 0,when the 60 is 0, I want to decrement another value only once, then repeat the count from 60 to 0.
This does not happen , the 60 counts down to zero and my second value immediately counts down to zero and execit the while loop.
Please any advice.
Thanks.
#include <LiquidCrystal.h>;
LiquidCrystal lcd(18, 17, 4, 5, 6, 7);
int secs = 60;
int valveDelay = 2;//2 x 60 secs = 2 mins
//====== count seconds ========
void countSecs()
{
while (secs > 0)
{
lcd.setCursor(13, 2);
lcd.print(" ");
lcd.setCursor(13, 2);
secs = secs - 1;
lcd.print(secs);
delay(200);
}
}
//=============================
void setup()
{
Serial.begin(9600);
Serial.println("Ver 1.02 - 2.6.2019");
lcd.begin (16, 4); //x,y
lcd.print("Ver 1.02 ");
lcd.setCursor(0, 1);
lcd.print("2/6/2019");
delay(3000);
lcd.clear();
lcd.setCursor(11, 2);
lcd.print(" ");
lcd.setCursor(11, 2);
lcd.print(valveDelay);//Print 2 on screen
}
void loop()
{
while (valveDelay > 0)
{
countSecs();
lcd.setCursor(11, 2);
lcd.print(" ");
lcd.setCursor(11, 2);
valveDelay = valveDelay - 1;
lcd.print(valveDelay);
int secs = 60;
}
}