🛠 Faire clignoter la LED RGB du Nicla Vision
Objectives
Get started with the Arduino Nicla Vision using a first sketch: turn the three onboard color LEDs on and off, and understand why the classic "Blink" example must be adapted for this board.
Hardware
- Arduino Nicla Vision (SKU ABX00051, 22.86 × 22.86 mm)
- Micro-USB data cable (some cables only support charging)
- Arduino IDE with the "Arduino Mbed OS Nicla Boards" core (ArduinoCore-mbed) installed via the Board Manager
Complete code
// Nicla Vision : LEDR=23, LEDG=24 (=LED_BUILTIN), LEDB=25
// >
const int RGB_PINS[3] = {LEDR, LEDG, LEDB};
void setup {
for (int p : RGB_PINS) {
pinMode(p, OUTPUT);
digitalWrite(p, HIGH); // LED eteintes
}
}
void loop {
digitalWrite(LEDG, LOW); delay(150); // vert ON
digitalWrite(LEDG, HIGH); delay(150);
digitalWrite(LEDR, LOW); delay(150); // rouge ON
digitalWrite(LEDR, HIGH); delay(150);
digitalWrite(LEDB, LOW); delay(400); // bleu ON
digitalWrite(LEDB, HIGH); delay(400);
}
Expected verification
The green LED, then the red one, then the blue one light up in turn in the sequence. The board's USB port is a USB CDC (VID 0x2341 / PID 0x025F): if the sketch compiles and uploads, the toolchain is correct. The core runs the sketch on the Cortex-M7 at 480 MHz; the second core (M4) is not needed here.
Common errors
- Including the Nicla_System library: its RGBled.h header contains a
#define Mode 1that collides with theModeenum in Mbed's InterfaceCAN.h — the sketch does not compile (open bug arduino/ArduinoCore-mbed#615 since January 2023). Hence the direct use of the LEDR/LEDG/LEDB pins above. - Forgetting DFU mode: the original bootloader is MCUboot; to force reflashing, double-press reset or open the serial port at 1200 baud, then flash via USB DFU.
- Charge-only cable: no COM port appears; try another cable.
- Inverting HIGH/LOW: if the LEDs stay on instead of blinking, the active level is the opposite of the assumption — invert the digitalWrite calls.
Other tutorials for this board
Code examples for this board
led_rgb.inoArduinoimu_lsm6dsox.inoArduinotof_distance.inoArduinomicro_pdm.inoArduinocamera_capture.inoArduinowifi_scan.inoArduino