Python For MegaPi

This is a Python library of MegaPi for Raspberry Pi.

How To Use:

Prepare for Arduino

Download the Arduino library for Makeblock https://github.com/Makeblock-official/Makeblock-Libraries/archive/master.zip

Copy the makeblock folder to your Arduino default library. Your Arduino library folder should now look like this

  • (On Windows): [x:\Users\XXX\Documents]\Arduino\libraries\makeblock\src
  • (On Mac OSX): [\Users\XXX\Documents]\Arduino\libraries\makeblock\src

Open Arduino IDE, choose the firmware from File>Examples.

firmware

Compile and upload firmware according to your board type.

Prepare for Raspberry Pi

On your Raspberry Pi, disable the login prompt from Desktop->Menu->Preferences->Raspberry Pi Configuration.

serial

Install Python library for Makeblock

sudo pip install megapi

The initial code for python:

from megapi import *
bot = MegaPi()
bot.start() #if using usb cable, need to call bot.start('/dev/ttyACM0')

python your.py

Wiring

Using MegaPi.

megapi

Using Me Shield for Raspberry Pi and RJ25 cable for Me Orion or Me Baseboard.

baseboard-pi-shield

Using USB Cable for Me Orion or Me Baseboard.

baseboard-usb-cable

See source code at https://github.com/Makeblock-official/PythonForMegaPi