mBot Bootstrap

| ⌛ 2 minutes read

📋 Tags:


Usage Guidelines

MakeBlock’s C API documentation is virtually non-existent. I tried already…

You will need to read through the source code to see what libraries have certain functions.

Minimally, you must import these 2 libraries:

0
1
#include <MemCore.h>
#include <MePort.h>

To make it easier to navigate through the documentation, I provide references to the APIs you will likely be using.

This is non-exhaustive, and you will need to read the docs to find out how to properly use the API. I will not divulge too much here because in industry, you will be reading tons of docs and need to figure things out yourself. No spoon-feeding here!

Useful References:

Sample usage: Ports

You want to access ports to read/write from.

 0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// Port_N should be PORT_1 or PORT_2 or ...
MePort my_port(PORT_N);  

// Get the pin number for the port's s1 and s2 
const int port_n_s1 = my_port.pin1();
const int port_n_s2 = my_port.pin2();

// To use the ports with Arduino, you use the pins as usual
pinMode(port_n_s1, OUTPUT); // setup
pinMode(port_n_s2, INPUT); // setup
digitalWrite(port_n_s1, HIGH); // usage
analogRead(port_n_s1); // usage

Sample Usage: Motor

Makeblock uses classes. You can think of it as variables that can perform functions (methods) and store many types of data at once.

You can sort of figure out how to use the functions work inductively from these examples:

0
1
2
3
// Port_N should be PORT_1 or PORT_2 or ...
MeDCMotor my_motor(PORT_N);
my_motor.run(75);
my_motor.stop();

Sample Usage: Line follower

0
1
2
// Port_N should be PORT_1 or PORT_2 or ...
MeLineFollower lineSensor(PORT_N);
int result = lineSensor.readSensors();

The other sensors' usage are left as an exercise to the reader.

If you have any issues using the library, please drop me a text.