newbies want code to control a well pump

We've tried putting together code to run a loop that will activate a relay (pump) for 1 minute on and 5 minutes off. This would be conditional on a sensor detecting water available in the well and a sensor in the tank indicating water is needed. The pump has to run for a short time and then rest because it is a low capacity well. Below is the code we drafted. The conditions seem to be ignored. Help Please.

int pump = 3;
int tank = 4;
int well = 7;



void setup() {

pinMode(pump,OUTPUT);
pinMode(tank,INPUT);
pinMode(well,INPUT);

}

void loop() {
 
{
digitalWrite(pump, HIGH);
delay(60000);
digitalWrite(pump, LOW);
delay(180000);

while ((tank)==LOW);
while ((tank)==LOW);
}

This line would be an infinite loop, hanging the Arduino, if the variable named tank happened to be equal to zero. Instead tank is equal to 4. Perhaps you meant to use digitalRead(tank).

while ((tank)==LOW);

If you want the program to respond to digital inputs, you cannot use delay(). You need to learn how to time events using millis() instead. See this tutorial https://www.baldengineer.com/blink-without-delay-explained.html

Write another program to just work with the sensor you have. When you understand the logic of how that works and how to monitor it's output signal, then incorporate that knowledge into your well program.

Karma for posting your code properly the first time!

Paul

You have misunderstood how to read the state of an input and to execute while its state is LOW
Here is an example of the correct method but there is much still to add to it

while (digitalRead(tank) == LOW)
  {
      //execute the code here
  }