Move forward count 5 then once is 5 stop the motor


#1

Hi MakerBlock,

Trying to the simple movement but the motor keep running non stop. please help. see the screen shot


#2

I think the problem is the “wait 1000 secs”. This does not stop the motors from running, but does pause program execution. Since you want to get “distance = 5”, you will be waiting 4000 secs, or 66 m 40 s (since distance started at 1, it will loop 4 times). Set the wait time to 1 sec and try it again.


#3

I have made changes to the project but now the motor doesn’t move at all anything that i have done wrongly here?


#4

OK, I made a couple of changes to your code and tested it on my mBot. I removed the “repeat until” and changed “if distance = 5” to “if distance < 5”. The wheels run for 4 seconds. MotorTest.sb2 (74.5 KB)

Hope this works.


#5

Thanks


#6