I've run across something very strange with my color sensor when using multiple sensors and multiple nested loops for a sumobot. I have 4 separate loops continuously monitoring the "optical", "ultrasonic" and two touch sensors ("touch1" and "touch4"). The main program of nested loops controls the motors in response to the sensors breaking different nested loops. I have attached a simple version that I removed the motor blocks from so you can follow it easier. When the program starts, it defaults to the "search" loop (innermost loop in main program). The optical sensor is looking for reflected light greater than 20 (white color). The first time I put a white paper over the optical sensor, it breaks the "search" and "charge" loops and proceeds to the "color" loop, as it should. However, it only works the first time! All the other sensors work as they should, all the time. Sometimes after multiple attempts, the color sensor will work again. Mostly it doesn't.
Here is where things get strange. If I remove any of the other 3 sensor loops, the optical sensor works perfectly. Another thing- If I change the color sensor in the "optical" loop from "compare reflected" to "change reflected-either direction" (keeping the value it is looking for the same), it works perfectly with all of the other sensor loops running. Also, using "change reflected- increase" or "decrease" doesn't fix it, only the "both directions" setting fixes the problem. Does anyone have an explanation of why this is happening? My only thought is that the multiple instances of the "wait for-color sensor" blocks are conflicting... but that should happen no matter how many other sensor loops I have running. It's driving me crazy helping kids troubleshoot why the optical sensor craps out. Any input greatly appreciated.