To map a specific LED in the BBC micro:bit LED matrix to the led0 alias in a Zephyr RTOS project (e.g., for the blinky sample), you need to create a Devicetree overlay that defines led0 using the correct GPIO pins.
The micro:bit v1 and v2 use a 5x5 LED matrix where rows are driven by GPIO pins and columns are sunk by GPIO pins. For your case:
- Row GPIO pin: 13
- Column GPIO pin: 4
This corresponds to a specific LED in the matrix. To use this LED as led0, you must define it as a GPIO LED in your overlay.
✅ Step-by-step: Create the overlay
-
Create a file in your Zephyr project:
boards/bbc_microbit.overlay
-
Add the following content to define led0 using the specified row and column:
/ {
aliases {
led0 = &my_led;
};
leds {
compatible = "gpio-leds";
my_led: led_0 {
gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>,
<&gpio0 4 GPIO_ACTIVE_LOW>;
label = "LED at row 13, col 4";
};
};
};
⚠️ Important Notes
- Row 13 is the source (driven high to turn on).
- Column 4 is the sink (driven low to allow current).
- This setup only works if the rest of the matrix is disabled or not interfering. The micro:bit uses a multiplexed matrix, so using a single LED like this may conflict with the matrix driver unless you disable it.
🧪 Optional: Disable the LED matrix driver
If you're using the micro:bit's built-in LED matrix driver (via display API), you must disable it to avoid conflicts:
In your prj.conf:
CONFIG_MICROBIT_DISPLAY=n
✅ Summary
- Use a Devicetree overlay to define
led0 as a GPIO LED.
- Use
gpio0 13 (row) and gpio0 4 (column).
- Ensure the LED matrix driver is disabled to avoid conflicts.
Let me know if you're using micro:bit v1 or v2 — the GPIO mapping is slightly different between them.