Skip to content

My first program to control my mBot

Selwyn Polit edited this page Jan 19, 2016 · 1 revision

These are some steps you can take to use this cute little robot:

Install mbot 3.x click Connect, install arduino driver plug in usb, click connect, serial port, COM3 (might be a different # than 3 on your system - use the highest value) Look for the check mark next to connect, serial port, com3 to confirm that you are connected.

click Edit, Arduino Mode. This will show a new panel on the right side with c code which will be generated as you drop blocks onto the center panel.

Always start with mbot program block create loop with control block: forever (or similar) Put robot blocks inside the loop eg run forward at speed 100 Don’t forget to stop the movement with a run forward at speed 0 otherwise the bot will roll on forever. Don’t forget to put a delay in so the motors can run for a bit otherwise there will be no movement

When you want to try your program on the robot, click the “upload to arduino” button. This will cause the c code to get compiled - you will see files flying by on the lower right panel, Then the compiled program will get transferred to the mbot. If you see, “please connect the serial port” then you may have missed the connect step above. I found one of my computers showed com3, com4, com5. Only com5 worked on that computer. If I tried com3 or com4, I had to restart the mbot program to make it work on com5.
I was able to get connected via bluetooth but it doesn’t seem like it is possible to upload programs that way.

Also it is possible to double click the mbot program block and that block will start executing immediately on the mbot. Sometimes lots of numbers and letters start rolling around in the lower right of the screen

eg. mbot program forever run forward speed 100 wait 1 second run forward speed 0

For using the button: mbot program forever if [button pressed] then run forward speed 100 wait 1 second run forward speed 0

Use the button to make mbot stop This will cause the robot to start running and it will stop when you click it’s button. To restart it, click the reset button.

make a Block called “go”

define “go” set led on board all to red: pick random 1-100 green: random 1-100 blue: random 1-100 run forward at speed 70

mbot program repeat until [button pressed] { [go block] } set led [led on board][all] red:0 green:0 blue:0 run forward at speed: 0

Clone this wiki locally