<Repeat for ever> in combination with <repeat 5 times>


#1

Hallo,
We want to program the mBot so that it runs up a firts the wall, turns to the right, drives up to the second wall and turns to the left. This pattern (please, see picture with the link) must be repeated 5 times. The distance to the wall is measured with the ultrasonic sensor. We encounter a problem with the combination of the function repeat forever (ultrasonic sensor) and repeat 5 times the parttern.

Is there anyone who can help us with the solution? Thanks.

J. De Winter


#2

Hi,

have you tried using a “wait until” coding block? You need a block that tells the computer to wait until the value of the distance sensor is less then for example 10 centimeters. I think that might solve your problem, because while the computer is “waiting” the mBot keeps on driving, just like you use the wait 5 seconds block when you want the mBot to drive for 5 seconds.

Greetings, PinkyPepper

P.S. Geven jullie programmeerlessen met de mBot op jullie school? Ik zag dat u uit Vlaanderen komt. Misschien kunt u nog wat met dit ideetje: http://programmeren-met-scratch.blogspot.nl/2017/06/basketballen-met-de-mbot.html


#3

Thank you very much for the response. The ‘wait until’ block offers a solution!
Best regards,
J. De Winter


#4