Multiple interrupts

I'm working on a smart sprinkler system project, and I want it to mainly react to different moisture sensor readings in different areas. After thought, I figured that using interrupts would be the best way to constantly check all "zones" of the yard without having to stop while one zone is being watered. Online interrupt videos have confused me a bit with the rising and falling edge talk. Basically, I want, say, 4 separate but nearly identical interrupts that are assigned to each zone that check moisture level over and over and water if needed. Something like this:

Int1:
if (moisture1 is too low)
water(zone1);
while(moisture too low);

Int 2:
if (moisture2 is too low)
water(zone2);
while(moisture too low);

etc.

My reasoning for using interrupts is that if all of these statements were in series in the main code, every time one zone needed to be watered, the code would stop there until watering was complete before checking the next. I just want some input as to whether this is a viable idea and if so, generally how to code it. Thanks

You don't need and should not use interrupts for such a slowly changing set of circumstances. Simply keep an array of status variables, one for each zone, and loop through it (after checking the time).

There is no reason for the Arduino to wait while one zone is being watered. Study the example posted in "Demonstration code for several things at the same time".

jremington:
You don't need and should not use interrupts for such a slowly changing set of circumstances. Simply keep an array of status variables, one for each zone, and loop through it (after checking the time).

There is no reason for the Arduino to wait while one zone is being watered. Study the example posted in "Demonstration code for several things at the same time".

Thanks for the info. My concern was that if zone 1 needed to be watered, zone 1 would be watered and the code would wait until that moisture was sufficient before even checking others, so a maximum of 1 zone would be watered at a time, and I wanted this system to be able to water as many as needed at any given time

I wanted this system to be able to water as many as needed at any given time

This contradicts:

the code would wait until that moisture was sufficient before even checking others, so a maximum of 1 zone would be watered at a time

If you want to water one zone at a time, you do not need interrupts. If you want to water any number of zones at once, you do not need interrupts.

PaulS:
This contradicts:If you want to water one zone at a time, you do not need interrupts. If you want to water any number of zones at once, you do not need interrupts.

The contradiction is because the second quote pertains to if the checking if's were in series in the main.
Currently, using the line
while(moisture is still too low);
after beginning watering will cause the code to halt until that condition was met, disallowing the rest to run during that interval. How else could I run the code to get around this issue?

How else could I run the code to get around this issue?

If you want to water multiple zones at once, you need to turn the water on, in each zone that needs watering, and then determine when to turn it off, on a zone-by-zone basis.

for(byte z=0; z<NUMZONES; z++)
{
   if(zoneNeedsWater(z))
      turnWaterOnInZone(z);
}
for(byte z=0; z<NUMZONES; z++)
{
   if(waterOnInZone(z) && zoneIsWetEnough(z))
      turnWaterOffInZone(z);
}

PaulS:
If you want to water multiple zones at once, you need to turn the water on, in each zone that needs watering, and then determine when to turn it off, on a zone-by-zone basis.

for(byte z=0; z<NUMZONES; z++)

{
  if(zoneNeedsWater(z))
      turnWaterOnInZone(z);
}






for(byte z=0; z<NUMZONES; z++)
{
  if(waterOnInZone(z) && zoneIsWetEnough(z))
      turnWaterOffInZone(z);
}

This helps a lot. Thanks much

To add to what @PaulS has said, you should only use WHILE and FOR for loops that complete in a few milliseconds.

You may find some useful ideas in the demo Several Things at a Time

...R