Mblock wait() function is not accurate


The mBlock wait() function seems to be not accurate.
I am using it for the mBot ranger.
Is this a known problem?

I have also created some code that makes a fix for this problem.
Thank you.


I have noticed a 2-10 second error when trying to use the wait block.
I used the timer(Is it based on Arduino’s millis?) to make a better function.


What is your code? Do you mean the wait {number} seconds block? Are you using device or sprite? Also, welcome to the forum!


I am using as a device for a mBot ranger.
I am using the wait{number of seconds block}


Just wondering, @Best_codes where is the code for mblock(specifically the blocks)?



What is your more specific code and error / problem?

Yikes! :grimacing: That’s a tough one! You can look around here:


The code varies actually, for sprites it is JS rendered on a canvas and for devices it is Python or C+.


Sorry for the later reply but the code is just:

The wait time is always more than a second.
I have timed it.
It is a problem for accurate turning.


So, this is for mBot Ranger… I have no idea why this is happening. Mine works fine. What is the Arduino C part of the code? (In the side panel). Sorry, I have been so busy.


It is fine…
The arduino code is blank for some reason…


Just checking:


Sorry for the bad drawing, I was in a rush. :slight_smile:


I did that.
It is just blank.


Because you are using the When 🏳 Clicked block. Use When mBot Ranger starts up instead. @V205


Ok. I will change it and see what happens.


If you are using the green flag block in live mode, then the problem is that the device and computer have to communicate to see what they should do. (Ranger runs C++, mBlock IDE runs JS, and your block combo is both). This has some lag. If you upload a code to the Ranger that does that but using the starts up block, it will be one second.


I won’t be able to do that.
The block is greyed out(because of the live mode on).
I can’t use the upload mode unfortunately so I can’t use the When mBot Ranger starts up


Why can you not use upload mode? If you really can’t, the best thing you can do is use the built-in delays in the motor blocks.


I can’t because:

  1. I am using bluetooth 4
  2. The upload using USB is problematic and often bricks the controller.

Oh well.

Is there a program that allows accurate turning?
Like in degrees?
For the Ranger?


There currently is not. :confused: You could make one though if you had upload mode. Why can your device not use just the USB cable exactly? Maybe you can try from another device.


Ok, sometimes I can use upload but I don’t like to because of the aforementioned problems.
If I could use upload mode I will…

So there are no resources for accurate turning?
I am trying to get the ranger to turn ~90 degrees

(I will probably hit post limit soon)


If you have taken the new user tutorial, then you will not hit a post limit for a while. (if you haven’t, just say

@discobot start new user



There are no resources, but you can do a code like this:

It might take some tweaking. I just threw it together on the spot :grimacing:.