Hi,
I have tried to use this in my code to store if the solenoid was closed or opened but not working...
I would like to use like:
if value is less than or equal to 60 and solenoid is closed, than open that
if value is less than or equal to 60 and solneoid is open, stay open ( solenoid_off)
if value is more than or equal to 61 and solenoid is opened, than close that
if value is lmore than or equal to 61 and solneoid is closed, stay closed ( solenoid_off)
Thanks for any help!
if ((moistvalue1mapped <= 60) && (solenoidclosed =true ))
{
solenoid_open();
solenoidclosed = false;
delay(200);
solenoid_off();
delay(200);
Serial.println(F("Solenoid is opened"));
lcd.setCursor(0, 0);
lcd.print("ON");
delay(100);
}
else if (solenoidclosed = false)
{
solenoid_off();
delay(200);
Serial.println(F("Solenoid is opened"));
lcd.setCursor(0, 0);
lcd.print("ON");
delay(100);
}
if ((moistvalue1mapped >= 61) && (solenoidclosed = false))
{
solenoid_close();
solenoidclosed = true;
delay(200);
solenoid_off();
delay(200);
Serial.println(F("Solenoid is closed"));
lcd.setCursor(0, 0);
lcd.print("OFF");
delay(200);
}
else if (solenoidclosed = true)
{
solenoid_off();
delay(200);
Serial.println(F("Solenoid is closed"));
lcd.setCursor(0, 0);
lcd.print("OFF");
delay(200);
}