PaulS:
Your last code was in reply #10. That code DOES have that line.
No i removed this line from my reply #10 .this to that because it was one from many attempt to use switch to start my counter .and as you see in code in reply #10 is more simple than the first code just to explain waht i want.
ok let me explain what is my code and what i want
i'll divide my code into two parts .the first one is to control the fan(my device) ontime and offtime as i record in IDE
void loop() {
unsigned long currentMillis = millis();
if (ledState1 == HIGH)
digitalWrite(led1, ledState1);
if ((ledState1 == HIGH) && (currentMillis - previousMillis1 >= OnTime1))
{
ledState1 = LOW;
previousMillis1 = currentMillis;
digitalWrite(led1, ledState1);
}
else if ((ledState1 == LOW) && (currentMillis - previousMillis1 >= OffTime1))
{
ledState1 = HIGH; previousMillis1 = currentMillis;
digitalWrite(led1, ledState1);
}
the second part it seems complex but it is my attempts,ok this part is for LCD,i made it to display my countdown of ontime1 and offtime1 of the devive
if (currentMillis - secondd == 1000) {
secondd = currentMillis;
}
if ((secondd1 == 0)) {
secondd1 = 60;
}
else if (currentMillis - secondd == 0) {
secondd1--;
lcd.setCursor(1, 1); lcd.print(" :");
lcd.setCursor(1, 1); lcd.print(hours1);
lcd.setCursor(4, 1);
lcd.print(" :");
lcd.setCursor(4, 1);
lcd.print(mint1);
lcd.setCursor(7, 1);
lcd.print(" :");
lcd.setCursor(7, 1);
lcd.print(secondd1);
if ((ledState1 == HIGH)) {
lcd.setCursor(14, 1);
lcd.print(" ");
lcd.setCursor(10, 1);
lcd.print(" FAN ON ");
}
else if ((ledState1 == LOW)) {
lcd.setCursor(14, 1);
lcd.print(" ");
lcd.setCursor(10, 1);
lcd.print(" FAN OFF");
}
if (currentMillis == 1000 && ledState1 == HIGH) {
allmint1 = (OnTime1 / 60 / 1000) - 1;
}
else if ((currentMillis - previousMillis1 == 0 && ledState1 == HIGH)) {
allmint1 = (OnTime1 / 60 / 1000) - 1;
}
else if ((currentMillis - previousMillis1 == 0 && ledState1 == LOW)) {
allmint1 = (OffTime1 / 60 / 1000) - 1;
}
else if ((currentMillis - secondd == 0 && secondd1 == 0)) {
allmint1--;
}
hours1 = allmint1 / 60;
if ((hours1 < 1)) {
mint1 = allmint1;
}
else if ((hours1 >= 1)) {
mint1 = allmint1 - (hours1 * 60);
this after many attempts to make right relationship between the counter of the device and what display in lcd
because in some attempts i saw the counter of device have timer not as displayed in lcd
ok till now i don't have problem in the last case and the timer running good
now i want to add code to increase and decrease ontime and offtime of the counter using switches and use EEPROM .to read and write