Maqueen Plus V2 MicroPython Documentation
website·Indexed 30 days ago
https://gbsl-informatik.github.io/maqueen-plus-v2-mpy/API reference and examples for the Maqueen Plus V2 robot using MicroPython. Includes documentation for motor control (motor_run), LED management (led_red, led_rgb), line tracking (line_sensor), ultrasonic distance sensing (ultrasonic), and compass heading (mq_heading). Supports versions 1.0.0, 2.0.0, 2.0.1, 2.0.2, and Next.
What's inside Maqueen Plus V2
- The Maqueen Plus V2 library allows developers to program the Maqueen Plus V2 robot (by dfrobot) using MicroPython on a Micro:Bit. The library provides a high-level interface to control the robot's motors, sensors, and LEDs, making it suitable for both beginners and advanced users.
Install Maqueen Plus V2.0 MicroPython library
To use the Maqueen Plus V2.0 library with MicroPython on a Micro:bit, use the online IDE at https://python.microbit.org/v/3. Copy themaqueen.pylibrary file into your project folder to import and use its functions in yourmain.py.from microbit import * from maqueen import * motor_run(Motor.LEFT, 100) sleep(1000) motor_run(Motor.ALL, 100) sleep(1000) motor_stop(Motor.ALL)Migrate LineSensor constants to v2.0.0
In version 2.0.0, theLineSensorconstants were renamed for better editor autocompletion. Additionally,SENSOR_ALLwas removed and replaced by a dedicated function.# Old constants -> New constants # SENSOR_L1 -> L1 # SENSOR_L2 -> L2 # SENSOR_M -> M # SENSOR_R1 -> R1 # SENSOR_R2 -> R2 # Instead of SENSOR_ALL, use: line_sensor_all()Calibrate Maqueen Plus V2.0 motors for straight driving
Because motors may not be perfectly identical,motor_calibrationallows you to set correction factors for specific speeds. The function takes a list of tuples(speed, correction_factor), where speed is between 0-255 and the factor is a value > 0. The system linearly interpolates between these points to ensure the robot drives straight. To reset calibration, pass an empty list[].from maqueen import * # Calibrate left motor with two measurement points # (Speed 25 with factor 1.3, Speed 200 with factor 1.2) motor_calibration(Motor.LEFT, [(25, 1.3), (200, 1.2)]) # Example with multiple interpolation points motor_calibration( Motor.LEFT, [ (25, 1.3), (50, 1.2), (100, 1.4), (200, 1.0) ] ) # Reset calibration for both motors motor_calibration(Motor.LEFT, []) motor_calibration(Motor.RIGHT, [])Calibrate Maqueen Plus v2 line sensors
If the factory calibration of the line sensors is no longer precise, you can recalibrate them manually:
- Position the Maqueen on a black surface (e.g., the back of the provided Track Map).
- Press and hold the Calibration Key for 5 seconds.
Install Maqueen Plus V2.0 MicroPython library
To use the Maqueen Plus V2.0 library with MicroPython on a Micro:bit, use the online IDE at https://python.microbit.org/v/3. Copy themaqueen.pylibrary file into your project folder to make it available for import in yourmain.pyscript.from microbit import * from maqueen import * motor_run(Motor.LEFT, 100) sleep(1000) motor_run(Motor.ALL, 100) sleep(1000) motor_stop(Motor.ALL)Migrate LineSensor API to v2.0.0
In version 2.0.0, the
LineSensorconstants were renamed for better editor autocompletion.SENSOR_ALLwas removed and replaced by a dedicated function.Constant Changes:
SENSOR_L1→L1SENSOR_L2→L2SENSOR_M→MSENSOR_R1→R1SENSOR_R2→R2
Function Changes:
- Use
line_sensor_all()instead ofSENSOR_ALLto get values for all sensors.
Calibrate Maqueen Plus V2 motors for straight driving
Because motors may not be perfectly identical,motor_calibrationallows you to set correction factors for specific speeds to ensure the robot drives straight. The calibration takes a list of tuples containing(speed, correction_factor). The speed must be between 0 and 255, and the correction factor must be > 0. The system linearly interpolates between the provided data points. To reset calibration, pass an empty list[].from maqueen import * # Set calibration for the left motor: at speed 25 use factor 1.3, at speed 200 use factor 1.2 motor_calibration(Motor.LEFT, [(25, 1.3), (200, 1.2)]) # Example with multiple interpolation points motor_calibration( Motor.LEFT, [ (25, 1.3), (50, 1.2), (100, 1.4), (200, 1.0) ] ) # Reset calibration for both motors motor_calibration(Motor.LEFT, []) motor_calibration(Motor.RIGHT, [])Migrate LineSensor constants to v2.0.0
In version 2.0.0, the
LineSensorconstants were renamed for better editor autocompletion. Additionally,SENSOR_ALLwas removed in favor of theline_sensor_all()function.Changes:
SENSOR_L1$ ightarrow$L1SENSOR_L2$ ightarrow$L2SENSOR_M$ ightarrow$MSENSOR_R1$ ightarrow$R1SENSOR_R2$ ightarrow$R2SENSOR_ALL$ ightarrow$ Useline_sensor_all()
Install the Maqueen Plus V2.0 MicroPython library
To use the Maqueen Plus V2.0 library with MicroPython on a Micro:bit, use an online IDE (such as https://python.microbit.org/v/3). Copy themaqueen.pylibrary file into your project folder to make it available for import.from maqueen import * motor_run(Motor.LEFT, 100) sleep(150) motor_stop(Motor.LEFT) motor_run(Motor.ALL, 100)Calibrate Maqueen Plus V2 motors for straight driving
Because motors may not be identical,motor_calibration(motor, calibration)allows you to set correction factors that are linearly interpolated based on speed. Thecalibrationparameter is a list of tuples containing(speed, correction_factor), where speed is 0-255 and the factor is a value > 0. To reset calibration, pass an empty list[].# Set calibration for the left motor with two measurement points motor_calibration(Motor.LEFT, [(25, 1.3), (200, 1.2)]) # Set multiple calibration points for linear interpolation motor_calibration( Motor.LEFT, [ (25, 1.3), (50, 1.2), (100, 1.4), (200, 1.0) ] ) # Reset calibration motor_calibration(Motor.LEFT, []) motor_calibration(Motor.RIGHT, [])Install Maqueen Plus V2.0 library for MicroPython
To use the Maqueen Plus V2.0 library with a Micro:bit, use the MicroPython online IDE (https://python.microbit.org/v/3). Copy themaqueen.pylibrary file into your project folder so it can be imported into yourmain.pyscript.from microbit import * from maqueen import * motor_run(Motor.LEFT, 100) sleep(1000) motor_run(Motor.ALL, 100) sleep(1000) motor_stop(Motor.ALL)