Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

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??

share|improve this question

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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