Example Code for micro:bit-Control Maqueen Lite via Analog Quantity

We have learned how to control the direction of the robot car in the last example. Now we will use analog quantity of the joystick to control the direction and speed of the robot simultaneously. Press the up an down buttons to control the movement of the loader, the left and right buttons to turn the robot car’s LEDs on/off.

Hardware Preparation

  • [DFR0536]GamePad for microbit ×1
  • micro:bit ×1
  • Maqueen Lite ×1

Software Preparation

  • MakeCode programming platform address: https://makecode.microbit.org
  • GamePad library: You can directly program this product on MakeCode without any third-party libraries.

Wiring Diagram

Plug the micro:bit into the GamePad for microbit.

Other Preparation Work

Download the program to the micro:bit motherboard and plug the motherboard into the gamepad.

Sample Code

Program for Maqueen:https://makecode.microbit.org/_WixF182kKK8T

Microbit Gamepad Expansion Board

Program for GamePad:https://makecode.microbit.org/_1WYL7aKctdav

Microbit Gamepad Expansion Board

Result

Run the program, toggle the rocker, and Maqueen Lite executes as follows:

Microbit Gamepad Expansion Board

Note: the greater the amplitude of the rocker, the faster the trolley will run.

Was this article helpful?

ON THIS PAGE

TOP