6

How do you program mindstorms to keep doing a task until either the IR OR the colour sensor state changes. I would like to use the wait block but it can only be either the colour sensor or the IF sensor. i want to continue the activity until either sensor changes to a specified condition.

6

One way of doing this is using a loop and interrupting it.

sample code

How it works:

The "Loop Interrupt" block stops all blocks running inside of the loop, so by interrupting the loop after either wait block, it will stop the other wait block. The type of loop doesn't actually matter because we never reach that point. I chose to wait for "Logic" with a value of "False" just so that it is more clear that we are not actually looping here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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