Using a sensor that can override buttons

Hi There,

So I'm slowly learning Arduino and have been building a garden irrigation controller. So far various solenoid valves are activated by push buttons and set to stay on for a set interval. I've managed to (finally) figure out millis() and the prototype is working pretty well.

What I am wondering now is whether or not there is a way to have a sensor (soil moisture) integrated into the system that will trigger the relays (solenoid valves) if moisture drops too low despite a button not being pushed. My thought is that it would operate as a fail safe.

Is this a realistic goal? If so, how would I integrate a sensor that takes priority but doesn't change the functionality of the push buttons.

Thank you for your feedback. If this is not enough information, I can attach code.

Building on your previous thread...
An if() statement can have more than one condition.

if (buttonIsPushed or moistureIsLow) ....

in code:

if(buttonState == HIGH || soilState == LOW) {
   // operate valve
}

Leo..

ahh, ok. I'll play with this. Thanks for the tip.

I was more thinking in the lines of a finite state machine, where both a button press or soil sensor reading would place the thing into watering state.

Of course you can also limit it to hours of the day or number of sprinklings per day, and then the sprinkling time based on the (average) temperature of the previous 24 hours, corrected for rainfall.