I don't see what is wrong with the way i made my program.

It looks like this.

enter image description here

The idea is that in the while loop [01] shall the robot move forward until it see something brown.

If it see something brown it should jump to the second while loop, where it will move forward it sees something brown, and if it sees something white it should move backwards.

But for some reason it immediately goes to the second while loop, and stays only at the first for few sec.? ??

What am i doing wrong??

1 Answer 1


Nothing is halting the "02" loop. It is running forever.

The problem with the second loop is that "brown" is the default. The switch looks for "white" and anything else uses the "brown" side of the switch. I suspect you want the lower half of the switch statement to be "any color but brown". If so, the "default" button needs to be selected for the "white" switch choice.

As for the "01" loop, the content of the loop always runs a first time. If at the end of one rotation, the color sensor does not see "white" it jumps out of the loop and the program enters the "02" loop.

I'd recommend using the LCD block to write the results of color sensor measurements to the EV3 LCD. It's a basic tool for debugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.