Using Python to Program Makeblock mBot


#1

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.
Thanks


#2

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.


#3

This link implies you can program in python

https://forum.makeblock.com/t/beginners-guide-to-mblock-5/10965


#4

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?
Thanks


#5

Welcome.
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.


#6

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


#7

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

#8

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


#9

The github library has been updated for python3
https://github.com/xeecos/python-for-mbot


#10

where you able to connect via bluetooth from the RPi?


#11

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.


#12

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


#13

Hello,
We are happy to annonce that miranda software (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.
(https://www.youtube.com/watch?v=Z3XBq9j_W9k)


#14

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


#15

@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!


#16

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


#17

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


#18

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

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


#19

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.


#20

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