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.