APIs for mBuild Modules

The more than 30 mBuild modules and supporting parts can meet your needs for electronic modules in various scenarios, including making your creative ideas come to life, comprehensive practice, project-based eduction, programming popularization, AI popularization, and robotics competitions.

Artboard 1@2x.jpg

 

Note: To use the functions of mBuild modules, you need to purchase the corresponding mBuild add-on kits or packs.

 

mBuild modules support multiple main control boards and can work with them through different Python API libraries, with the same functions.

Import the corresponding API library when using mBuild modules with a main control board. In addition, mBuild modules can also be used as a standalone device.

For example, to use mBuild modules through CyberPi, import the cyberpi library.

 

from cyberpi import *

 

To help you use the APIs more efficiently, the application scenarios of the APIs are labelled as follows:

资源 3@2x-8.png: indicates that an API supports Python 3 programming and can be used in Live mode on the mBlock Python editor.

资源 4@2x-8.png: indicates that an API supports MicroPython programming and can be used in Upload mode on the mBlock Python editor.

资源 6@2x-8.png: indicates that an API supports both Python 3 and MicroPython programming and can be used in both Live and Upload modes on the mBlock Python editor.

 

To use mBuild modules through Halocode, import the halocode library.

from halocode import *

To use mBuild modules as a standalone device, import the mbuild library.

from mbuild import *

 

Common parameter index

All APIs for mBuild modules include the parameter index, which indicates the place of a module among the ones connected to the main control board. Generally, the default value is 1. Therefore, if only one module of each type is used, you don't need to set this parameter. When two or more modules of the same type are used, you need to set index to 2, 3, 4, or another number to specify the second, third, forth, or another module. For example, motor_driver.set(100, index = 2) indicates that the output power of the second motor driver is set to 100.

Input modules

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.