thanks PaulS for your reply and thanks for inform me how to post and reply here .
It's ok i made auto format it's write this is a big different
ok i'll explain what i want
i want to control a fan( ON 10 minutes, OFF one hour )and repeat contentiously . no problem for this for me and i see my countdown in my LCD ,but in this case if need to change ontime and offtime from IDE . OK no problem till now
but it's not practical for me because i change from IDE ,i need to change ontime and offtime using arduino and save the change in arduino (ok you told me to use EEPROM.) i try but my little experience doesn't help me
for example i need to change ontime1 from 600000 ms to 1200000 (two minutes)and change offtime1 from 3600000 ms to 4000000 using button to increase and other button to decrease and display my change in LCD and start counter after i finish the change using another or the same button
thanks
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
int sw = 3;
int led1 = 7;
int ledState1 = HIGH;
unsigned long previousMillis1 = 0;
long OnTime1 = 600000 ;
long OffTime1 = 3600000;
long secondd ;
long secondd1 = 60;
int allmint1 ;
int mint1 ;
int hours1 ;
void setup() {
Serial.begin(9600);
lcd.begin(20, 4);
pinMode(led1, OUTPUT);
lcd.setCursor(1, 0); lcd.print("H :M :S");
pinMode(sw, INPUT_PULLUP);
}
void loop() {
unsigned long currentMillis = millis();
while (!digitalWrite, sw) {
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);
}
/////
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);
}
}
}
}