Example Code for micro:bit-Infrared Remote Control
Last revision 2025/12/19
Learn to control the Maqueen V5 Robot Car with micro:bit using infrared remote control. The article offers detailed hardware and software preparation steps, along with sample codes that demonstrate reading key values from the remote and controlling car movements. Perfect for robotics enthusiasts and those interested in microcontroller projects.
Hardware Preparation
- Maqueen V5 Robot Car: 1 (Purchase Link: https://www.dfrobot.com/product-2937.html)
- micro:bit Mainboard: 1
- 3 AA Batteries: 1 set
- Infrared Remote Controller: 1 (Purchase separately)

The following table shows the buttons of the infrared remote controller and the corresponding key values for your reference:

The example effect is as shown in the following figure:

Software Preparation
- MakeCode Platform: https://makecode.microbit.org/
- Maqueen Library: Load via MakeCode Extensions (search for "dfrobot" and select "Maqueen")
Other Preparation Work
- Ensure the micro:bit mainboard is properly plugged into Maqueen V5.
- Install the batteries correctly.
- Turn on the power switch.
- Purchase an infrared remote controller (not included by default).
Sample Code
Example 1: Read the key value of the infrared remote controller
Program Description:
This example demonstrates displaying the received key value of the infrared remote controller on the serial monitor. The key value is displayed in decimal.

Example 2: Infrared remote control car
Program Description:
- This program demonstrates controlling the car to move forward, backward, turn left, turn right, and stop using an infrared remote controller.
- Press the "2" key on the remote controller, the car moves forward; the "8" key for backward; the "4" key for left turn; the "6" key for right turn; and the "5" key for stop.
Program link: https://makecode.microbit.org/_cfkH1b0xgfkE

Result
- Example 1: Key values from the infrared remote are displayed on the serial monitor.
- Example 2: Car moves according to the infrared remote commands.
Was this article helpful?
