Final word on Megapi Pro, Raspberry Pi, and Python?


#1

Hello,

My son would like to program hi Megapi Pro using python rather than the the scratch based code of Mblock.

Looking at some postings on the forums, I get mixed messages on whether or not this is possible.

It would seem that the simplest thing would be if the he could program the Megapi Pro after it is attached to his Raspberry PI via USB cable…using Python. Is this possible, or is this beyond what the Megapi Pro offers?

Thank you


#2

It is possible there are libraries/packages available to directly program the megapi using python. But do understand that the Megapi is a microcontroller based on an arduino and therefore also on arduino programming. Using a python library to directly program it is a workaround/translation/conversion.

In my opinion it’s better not to use the kind of libraries and packages but rather write an Arduino program (c++ code) which expects commands and write a python program to sent those commands. This sounds more complicated than it is. Take a look at my Github where I posted a project about my mBot which I control using a python script.

Upside of writing your own code is that you understand it because in the beginning it will probably very basic. Whereas using packages like mentioned can be fairly complicated and when your code doesn’t work out like you want it too debugging can be a pain (ofcourse also depending on your skills)

Let me know if you have some more questions.
Your sons project is nice and offers many possibilities because he won’t be limited by what the makeblock software is offering but it comes with a challenge.


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.