Basic Logic Question (boolean)

I am building a project that uses preset times to trigger relays. I also use Blynk to remotely access the project. That said, I seek to expand the functionality by being able to change pin states that are previously accounted for in code. Essentially, as my sketch is now, it tests the RTC against some preset times and sets the pin HIGH till it's time to set the pin back to LOW. This however, blocks my ability to change the pin state remotely as the respective pin is being held LOW.

Upon reading the code and comprehending (to the best of my ability) what is happening, I got the idea the when using boolean, I can create a parameter by which the boolean becomes true if the criteria of the test is satisfied. I realize that the snippet of code below does not revert the boolean back to it's default state, and is likely the reason why the pin remains HIGH. However, I am conflicted because when reading the code in a literal manner, I see that the boolean can only be true within the confines of the test, so why does the pin not revert outside of the test boundary?

int PIN = 13;
bool pumpRunning = false;

void checkPump()
  DateTime now =;  // reads time at beginning of loop

  if (now.minute() < 30)
    pumpRunning = true;
  if (pumpRunning == true)
    digitalWrite(PIN, HIGH);

I still can access the pin with Blynk, but only for a moment due to timer intervals of the function.

The project is a hydroponics controller, the pin is a water pump and the preset times are the feeding schedule. However, I would also like to activate the pumps at varying times to pump out spent nutrient solutions, or to mix new nutrient solutions, or other needs.

I'm not sure what you mean by true only in the confines of the test, but I think you have a false assumption. The boolean will be true until you set it false and, since it is in global scope, will be true everywhere in the code.

I would remove the boolean and write the function like this:

void checkPump()
  DateTime now =;  // reads time at beginning of loop

  digitalWrite(PIN, (now.minute() < 30) ? HIGH : LOW);


You probably need a boolean that indicates whether the system is being manually overridden. If this variable is true you would look at buttons or however you're going to control the pump, if not you control the pump as usual. If override is set by a toggle switch, maybe something like:

static int  pumpPin = 13;
static int  overridePin = 2;

boolean manualMode = false;

void loop() {

  // if toggle set to override
  if ( digitalRead(overridePin) == HIGH )
    // stop motor if not in manual
    if ( !manualMOde ) digitalWrite(pumpPin, LOW);

    // enter manual mode
    manualMode = true;

    // check manual buttons

  } else {

    // auto control
    manualMode = false;



I see what you're saying. So if the button remains false, then my timed function may proceed in holding the pin LOW? Basically, just make a boolean for each pin being used and when button is pressed, boolean becomes true and the command to hold the pin LOW cannot execute.

Thanks for clearing that up for me if I have it right now.

So if the button remains false,

Buttons can not be false. Switches ARE. The state of the switch can be pressed or released, which means that the pin it is connected to is HIGH or LOW. Nary a true or false in sight.

The Arduino does NOT operate on illogic.