Read multiple pins

Hi all

Is there an easier/more elegant way of reading multiple output pins than below

//Pin           3                        4                        5                       6                         7                        8                       9                        10                       11                       12                       13                       14                       15                       16                      17                       18                        19
  if(bitRead(PORTE,5) == 0 && bitRead(PORTG,5) == 0 && bitRead(PORTE,3) == 0 && bitRead(PORTH,3) == 0 && bitRead(PORTH,4) == 0 && bitRead(PORTH,5) == 0 && bitRead(PORTH,6) == 0 && bitRead(PORTB,4) == 0 && bitRead(PORTB,5) == 0 && bitRead(PORTB,6) == 0 && bitRead(PORTB,7) == 0 && bitRead(PORTJ,1) == 0 && bitRead(PORTJ,0) == 0 && bitRead(PORTH,1) == 0 && bitRead(PORTH,0) == 0 && bitRead(PORTD,3) == 0 && bitRead(PORTD,2) == 0){
Do something
}

Note: they will not always be in order could be read pind 2 to 6 then 8 to 19, etc

Cheers
Grant

Is there an easier/more elegant way of reading multiple output pins than below

If the pins don't all belong to the same port, no. Except that it really should not be necessary to read output pins.

You know (or could remember) what you set them to.

I could remember what I set them to by using a boolean or something for each output but that then requires extra code that would not be required if doing it the above way and then I would still need to test those booleans with the same above method anyway no?

The reason I want to know if any other outputs are HIGH is that I only want 1 of the 18 outputs to be HIGH at a time and if one is HIGH then the output that is trying to go HIGH must wait until the other one has gone LOW before going HIGH itself. (Hope this makes sense)

Is there an easier/more elegant way of reading multiple output pins than below

As Paul syay, why are you reading output pins ? What other value could they have beside what your program previously set them to ?

If absolute speed does not matter (does it matter in your project ?) you could put the pin numbers in an array and iterate through it reading the state of the pins using digitalRead() and add the reading to a running total. At the end of the for loop if the total is zero then none of the inputs was HIGH when read.

As Paul syay, why are you reading output pins ? What other value could they have beside what your program previously set them to ?

I am making a sprinkler program. There are 18 channels each having 3 programs. each program can be set for any number of days for any watering time at any time of the day. That gives 54 variables that if not set up just right can clash with one another. Say one program watering every 2 days for 30 mins from 1215 and another program watering every 5 days from 1240 for 20 mins eventually they will clash. I figured monitoring the output pins off all channels was an easy way to see if any other program was running and if so wait until it has finished.
If there is a better way I am all ears.

Speed is not really a factor for this project. I do like your idea of putting them in an array and having a running total I had not thought of doing it that way.