3

I have a program that uses the colour sensor to progress that program. The colours are in a certain order. If the wrong colour is detected, the program stops.

I want to restart the program from the beginning automatically if at any point the wrong colour is detected. Please note that I already have a loop encompassing the entire program if the colours are detected in the correct order.

1 Answer 1

2

Please note that I already have a loop encompassing the entire program if the colours are detected in the correct order.

How about creating another loop for the failure case?

Start loop 1 (correct order)
Start loop 2 (wrong order)
Initialization
Check for colours
  If correct order
    Do something
    End loop 1 (correct order)
  Else
    Do some other thing (or not)
    End loop 2 (wrong order)

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.