thanks
the problem for me is that the first time for me to make code for arduino may be i have some problem in code or my question but i try to be better
ok i will ask by another statement
i need to make change in my code to control my device timer "to increase or decrease on time and off time
and you told me to try EEPROM.i try this
in the other way i need to start millis() or make pause by using while()for the button but i can't see any text in lcd
#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);}
}
}}