Using Python to Program Makeblock mBot


Hi Forum,
I have an MBot and have downloaded Makeblock 5 to get the robot to perform actions using scratch.
Using scratch is working fine however, I want to program it using Python but I’m not sure how to start? I see the 2 tabs on my top right of screen, one for Blocks & another for Python. Can anyone give me some tips to get me started?
Where would I add my Python script to get the robot to follow those actions?
Any suggestions appreciated.


I don’t think you can program the Mbot using Python. I’m pretty sure it only supports Arduino and I have never programmed with it so I can’t really give you tips.


This link implies you can program in python


Thanks dr-roboto,
It looks like I can use Python to program the Sprites only, not the robot.
Once I add the MBot the option for Python changes to Arduino.

There is some discussion about putting a block of Python code in a block that the Arduino can then read but I have no idea on how to do this?
Otherwise, it looks like I’m going to need a Raspberry Pi.

Does anyone have a way to use Python inside Arduino?


I went with the Raspberry Pi option and use python on the Pi to run the Makeblock robots. The Pi is a great computer and the Arduino is a great controller.


Sounds like a plan, can I ask what Py products/package did you buy?
I’m just looking at them now & there’s sooo many.
I assume I can still use the sensors etc that came with the mBot.
I’ve got a bunch of extras with my mBot so I guess I’ll just need the Board with various connectors?
What would you suggest?
Thanks Pete


I had to convert a python module from python 2.x and modify it.
I have successfully tested the following:

  • ultrasonic sensor
  • onboard buzzer (music)
  • onboard LEDs
  • onboard light sensor
  • M1 and M2 motors
  • servo attached to RJ25 adapter


Cool, thanks again,
At least I can code a Sprite in the meantime.
Cheers Pete


The github library has been updated for python3


where you able to connect via bluetooth from the RPi?


no sure I understand your question. The RPI is connected the the MBot with an USB cable and the library uses this serial connection. I talk to the RPI with a wifi connection.


Actually only Scratch and Arduino programming are supported for mBot in mBlock5.


We are happy to annonce that miranda software ( has now a gateway to generate c code from
Python. So now, from miranda, with one click you can program your mBot with your Python script.


I think you can program python coding into the mbot 2 / mbot neo so if your willing to blow your money on that…


@everyone @Oscar You can’t program mBot in Python. The board won’t compile it. It runs C+ (Arduino C) only. :confused:

If you want a robot that works with Python, you can use Codey Rocky or mBot 2 (Neo), which both support Python programming (mBot Neo would be best).

Good luck!


Thanks to all for your help.
I bought a Raspberry Pi and can now program using Python.
Thanks again!


Your welcome, though Python is hard for me :smile:


@Oscar No problem! The Raspberry Pi is a really fun board. :smiley:

If you need help with anything else, be sure to ask!


Switch to the Python tab in Makeblock 5, where you can write your Python code to control the MBot. Add your Python scripts directly into the script editor provided in the Python mode to define the actions you want the robot to perform.


@AdeaBaku mBot can not be coded in Python. Also, please stop posting spam links on the forum. Thank you!