Python for Ranger


I would like to teach Python using the Ranger as it has more sensors and encoder motors which makes it a bit more interesting than the mBot.

Are there any python libraries specifically for the Ranger e.g. 12 LEDs on board etc?

Using the mBot python library from github and after installing pyserial etc I have managed to get the motors to work but the light sensor appears to be the wrong port and doesn’t change with the lighting.

I’m guessing a lot of these libraries have already been written. Could Makeblock at least provide a list of ports for the on board sensors - gyro, sound sensor, light sensors 1 & 2 and LED outputs and encoder motor outputs.

Thanks in advance!


@tec_support, the pins assigned to each onboard device would be generally useful for the mCore, Auriga, and Orion boards. Can one of the engineers help with that?


The Auriga is essentially an Arduino Mega (AT2560) so rather than look for mBot Ranger-specific libraries I would suggest just treating it as an Arduino Mega and using the Makeblock-official library on Github. You might want to check out Github to see if anyone else has created a Makeblock-specific Python library (I recall seeing one for the MegaPi).

My second book (in progress) is essentially covering the mBot 1.0/1.1 with the Arduino IDE and at some point I’ll address the Auriga (the Orion seems to have been superseded by the Auriga).

Getting a list of pinouts for the onboard devices would be generally useful. I’ll compile one if @tec_support can’t get one.


Thanks Chuck, I’ll check out the megaPi library, I was assuming that it would require the RaspPi but I notice now on the mBot library they say it’s been tested with RaspPi so I guess MegaPi will have the whole library for all sensors/actuators.

I would love a guide on how to understand the methods in the library. So many functions/methods have port in them and I’m not sure if port is referring to port 1,2,3… or /dev/tty? So just understanding the api is a problem for me at the moment.

Could you point me at any resources to help me learn about this hardware level programming?



Hi @vtrob,

This is a link to the Doxygen source for the Makeblock-official library source at Github. I’m not sure that it will answer your questions, but it’s where I started.

Generally speaking, the port refers to the RJ25 plug on the mCore, Auriga, or Orion boards. /dev/tty generally refers to a serial connection of some sort.

The best advice I can offer is to get Simon Monk’s books on Arduino Sketches and work through them to get a background for Arduino programming because the Makeblock boards are based on the Arduino Uno (AT328P) or the Arduino Mega (AT2560).


Thanks for the advice @chuckmcknight . Much appreciated. I’ll try the book and I think I’ll have to find a maker/arduino group nearby otherwise this is too slow & painful just searching the web for all the tricky details. I’m used to coding higher level software in python not hardware interfacing in C. Steep learning curve!


Well, a lot of people think C is pretty challenging, but in the Arduino environment you are typically not directly using pointers too much (if at all) so it’s a much shallower learning curve (which was the intent). :slight_smile:

If you are comfortable writing Python, the only two things you’d need to pay attention to are the curly braces for methods/loops/decisions and ending statements with a semi-colon. Dr. Monk makes it pretty simple come up the curve for the Arduino. :slight_smile: