Hi everyone, so I wanted to make a program where: When the bottle of water is full, the solenoid will turn off BUT my problem here is the message. Whenever the solenoid is switched on (while filling the bottle), serial monitor shows the message "SOLENOID ON" multiple times then it will display "SOLENOID OFF" multiple times when the solenoid was switched off. How can I display just one message if the solenoid was either on or off? My code looks like this:
if (WaterValEmpty == 0) // this is for the sensor
{
digitalWrite(solenoid, HIGH);
Serial.print("SOLENOID ON");
}
else if (WaterValFull ==1) // this is for the sensor
{
digitalWrite(solenoid, LOW);
Serial.print("SOLENOID OFF");
}
Please help and thank you in advance.