Infrared sensors and having 2 'modes' on arduino

I currently have 2 infrared sensors set up and have them so as you pass your hand through each one lights up a seperate LED, Sensor 1 with yellow and sensor 2 with green.

I now want to make the sensors switch between, what i have labelled as, modes. This being when sensor 1 is in mode 1 (one steup in the code) shown with the yellow LED lit. A green LED will also be lit and when sensor 2 is triggered it will turn this off and it will come back on when the user moves their hand out of sight of the sensor.

When sensor one is triggered it will turn off the yellow LED an turn on an orange LED, showing it is in mode 2, and the green LED to a white. This now means when sensor 2 is triggered it will turn off the red LED and when the hand moves out of the sensors range the light will turn on again.

However I also am looking to have mode 3, so when sensor 1 is triggered, the orange LED turns off and a white LED is lit, however the green LED in mode 1 now turns on, with the red from mode 2 turning off. This green is again interacted with in the same way as previously.

When sensor 1 is trigered again it will toggle back to mode 1.

So overall in a very long way i am asking whether you can have a sensor toggling through 'setups' (modes 1 2 and 3) with some of the modes (1 and 3) have the same outputs....

In theory it seems easy but i was wondering if anyone could build on this with me :S im very confused.


sensor toggling through ‘setups’

Put simple yes this is perfectly possible.

You software needs to have a variable (sometimes called a state variable) that defines what mode you are in. There is a switch statement in the loop() that directs the code to the correct routines for that mode. In those routines will be code that examines for a mode change and it it finds on it changes the state variable.
Then next time round the loop() a different set of routines is called.

You need to plan it out on paper with a flow diagram to make it clear to yourself what you are doing.