Using delays inside loop

I'm currently working on an arduino code for a line follower competition. The rules say the robot has to wait on many occasions during his circuit. (Like when it detects a red zone it has to wait 4 seconds then keep going).

So inside my loop I have my readSensors() function which should keep reading at regular intervals. How should I implements the delays to make the robot wait without stopping other stuff like readSensors() function ?

First circuit :

Second circuit :

Notice the various stops throughout the circuits.

Thank you


Look at the BlinkWithoutDelay example in the IDE.
It uses the principle of noting the start time of an event then periodically checking if the required interval has elapsed. If yes then do the next thing. If no then do something else like reading sensors before going back to check again if the required interval has elapsed.

Another thing to think about is NOT stopping for 4 seconds every time the sensor sees red. You want to stop ONCE when the sensor sees red.