🛠 Afficher du texte sur la matrice LED 5×5
Objectives
Discover the micro:bit V2 board (Nordic nRF52833, Cortex-M4 64 MHz) by displaying text and images on its 5×5 LED matrix (25 LEDs). By the end of this tutorial, you will know how to flash a MicroPython program via drag-and-drop and scroll a message.
Hardware
- 1 micro:bit V2 board
- 1 micro-USB cable
- 1 computer (for the python.microbit.org editor or Mu)
Complete code
from microbit import *
# Message défilant, puis images prédéfinies
display.scroll("BONJOUR MICROBIT", delay=80)
while True:
display.show(Image.HAPPY)
sleep(800)
display.show(Image.HEART)
sleep(800)
display.show(Image.TARGET)
sleep(800)
Save from python.microbit.org: the .hex file is copied to the "MICROBIT" USB drive (DAPLink interface chip, KL27Z or nRF52820 depending on revision). The program starts after a short restart.
Expected verification
The message "BONJOUR MICROBIT" scrolls letter by letter, then a smiley, a heart, and a target are displayed in a loop. The board barely heats up: this is normal, as the LEDs are software-multiplexed.
Common errors
- The .hex file does not appear on the drive: try a data cable (some cables only provide charging).
- "MICROBIT" not mounted: the interface firmware is too old (< 0247), update it via microbit.org.
- Confusing V1 and V2: only the V2 has the microphone, speaker, and touch pad on the logo.
- Writing
display.scrollwithout parentheses or forgetting to importfrom microbit import *.
Other tutorials for this board
Code examples for this board
coeur.pyMicroPythonboutons.pyMicroPythonpodometre.pyMicroPythonlumiere.pyMicroPythonmusique.pyMicroPythonradio_ping.pyMicroPython