excuse me I learned the arduino program and I want to make a project at. but the problem is in the delay and while so I have to wait for the delay program to stop, and the difficulty to make it work properly ... please help me how the project is correct ... my native language is Indonesia, so sorry if my english is not good. thank you
void loop()
{
delay(100);
if (digitalRead(Psen) == LOW) //listrik on
{
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" ----PLN ON----");
if(digitalRead(Gsen) == LOW){
delay(60000);
//if (millis()- durasi5 > jeda5) {
//durasi5 = millis();
if (digitalRead(Psen) == HIGH) {
digitalWrite(gon, LOW);
digitalWrite(pon, HIGH) ;
digitalWrite(gstb, HIGH);
}
else
{
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" TEGANGAN PLN");
digitalWrite(gstr, HIGH) ;
while (timeDelay3 > 0) { // matikan genset
if (millis()- durasigstr > jedagstr) {
durasigstr = millis();
digitalWrite(gon, HIGH);
digitalWrite(pon, LOW) ;
if (statusgstr == HIGH) {
statusgstr = LOW; }
else {
statusgstr = HIGH; }
digitalWrite(gstb,statusgstr);
timeDelay3 = timeDelay3-1000; }}
}
}
else {
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" TEGANGAN PLN");
digitalWrite(gon, HIGH); //kontraktor gst of
digitalWrite(gstr, HIGH) ; // stater of
digitalWrite(pon, LOW) ; //kontraktor listrik on
}
}
else
{
lcd.clear();
lcd.setCursor (0,0);
lcd.print("TEGANGAN OFF");
digitalWrite(gstb, HIGH) ;
if(digitalRead(Gsen) == HIGH) //jemset of
{
digitalWrite(pon, HIGH);
digitalWrite(gon, HIGH);
digitalWrite(gstb, HIGH) ;
startter1();
reset();
}
else
{
digitalWrite(pon,HIGH);
digitalWrite(gon, LOW);
digitalWrite(gstr, HIGH) ;
digitalWrite(gstb, HIGH);
lcd.clear();
lcd.setCursor (0,0);
lcd.print("TEGANGAN GENSET");
}
}
}