I'm building a robot that can do multiple jobs so in my void loop() I'll have a menu to select which option the user wants to do which I have yet to program. I have all my code pasted below but the main focus is friendSafari() and analogValue(). My scenario is this: Let's say I got my menu working and I select the option Friend Safari which calls friendSafari(), I want friendSafari to keep looping constantly until either A. The user terminates the program or B. It finds a shiny Pokemon which calls shinyPokemon() which just makes an RGB light go different colors and stop the program essentially (Indicated by the photoresistor getting a read of under a certain light level after 11.3 seconds of the light level dropping the first time) During the friendSafari() function I need to result my variable "Value" over and over and over and over so that I get the timing right so I wanted to make it its own function.
My big question is:
How do I get my program to keep looping friendSafari() after getting redirected from void loop() while getting my "value" variable updated from another function while still running friendSafari() but then once the special case happens quit friendSafari() and go to shinyPokemon() for the rest of time.
Code: (Most of it is a WIP and I'm sorry if it's messy I figured it's best to post all of the code so I don't miss anything)