Example Code for Car Turning and RGB Light Control

Last revision 2026/01/20

This article explains how to control car turning using differential motor speeds and advanced RGB lighting setups, featuring the Maqueen Plus V3 and optional micro:bit V2 buzzer activation.

Introduction

This example demonstrates how to control turning by setting different speeds for left and right motors. It also showcases advanced RGB lighting:

  • Bottom RGB strip (connected to P1 on V3, unlike P15 on V2) uses rainbow color mode (hue range: 1–360).
  • Front vehicle lights display two distinct RGB colors using V3’s enhanced color control.
  • If using micro:bit V2, the built-in buzzer can be activated via the onboard speaker block.

Hardware Preparation

  • Maqueen Plus V3
  • micro:bit V2 (optional, for buzzer demo)
  • USB cable

Software Preparation

  • MakeCode with Maqueen Plus V3 extension
  • Ensure correct pin assignment (P1 for bottom RGB on V3)

Wiring Diagram

All components are integrated. No external wiring needed.

Sample Code

View on MakeCode

Key Features:

  • Left motor: speed 50 forward; Right motor: speed 0 → gentle right turn
  • Bottom RGB: set rainbow hue block with dynamic hue value
  • Front lights: individually set to different RGB values
  • Optional: music.playSound(...) for micro:bit V2 buzzer

Result

  • Robot performs smooth turns based on differential motor speeds.
  • Bottom RGB strip cycles through vibrant rainbow colors.
  • Front lights glow in two custom colors simultaneously.
  • (If V2) Buzzer emits sound when triggered.

Was this article helpful?

TOP