Difference between "mBot Program" block and "When (green flag) clicked" block?


#1

What is the difference between the “mBot Program” block (in “Robots”) and “When (green flag) clicked” block (in “Events”) ?

I have the mBot and am programming in mBlock 3.2.2 (Windows 10).

I’ve tested both blocks at the top of my programs. The “When (green flag) clicked” block starts my program and gets the mBot moving. When I place “mBot Program” block at the top, my program does nothing.

What is the point of the “mBot Program” block? How do I trigger a program with this at the top to start?


#2

@dpohl,

There are two ways to run an mBlock program.

1, click on the flag, which will run all three “when ‘green flag’ clicked” blocks.
2, click on each “when ‘green flag’ clicked” block one at a time will play that block only.

When you want to run an “mBot Program”, click on it, not the ‘green flag’.

The screen will change, and you should see some actual ‘C’ code appear. If you now click on the “Upload to Arduino” button, The code will compile and get uploaded to the mBot and execute (run).

The difference between “when ‘green flag’ clicked” and “mBot Program” is how and where the program is run. “when ‘green flag’ clicked” runs on the computer, which communicates actions to the mBot. “mBot Program” compiles the code and uploads it to the mBot and run on the mBot.

With the “mBot Program”, once the upload is complete, you can unplug the USB cable, connect the batteries (if they are not already connected), hit the reset button, and the mBot should run by itself.

Hope this helps.

Mike


#3

You will also notice that timing dependent operations (reading sensors, controlling motor movement) will not suffer from the over the air serial lag times if the program is running locally on the mBot. :slight_smile:


#4

Mike, Chuck - Thank you for your detailed answers.

Is there some mBlock programming reference that answers questions like this, or did you figure that out from trial-and-error?


#5

Bit of both. There is an mBot programming manual here that goes into basic things. The rest is from trial and error.