Hi, it needs to latch the relay when the first sensor is triggered, then unlatch it when the second one is triggered, and so forth.
@geobee,
Perhaps if I explain the assumptions I made (for the code in reply #2) you can see how they differ from what you just stated.
My assumptions:
The sensors output an active high pulse when triggered long enough for the Arduino to easily respond to. The maximum pulse duration is unknown.
The initial (power-up or after reset) state of the relay is off.
The relay should turn on when the first sensor becomes (or is) active, remaining on while the first sensor is still active.
Once the first sensor goes inactive, the relay should turn off when the second sensor becomes (or is) active, remaining off while the second sensor is still active.
Once the second sensor goes inactive, repeat ad nauseam.
That implies that if both sensors are active at the same time (i.e. their pulses overlap), whichever came first initially 'wins' then as they become inactive, whichever is last to become inactive 'wins'.
I haven't even covered any requirement for debouncing. If you were dealing with mechanical switches or interrupted beam IR sensors you might choose to specify *either* 'Any change of sensor state shall be ignored until it has been stable for 10 ms.' *or* 'A change of sensor state shall be acted on immediately then further changes for the same sensor ignored until it has been stable for 10 ms, then acted on if required' or similar with a different debouncing period.
As you can see, specifications for code in human language can get rather complex if you need to nail down all ambiguities.