🛠 Faire clignoter la LED RGB du Nicla Vision

Arduino Nicla Vision · debutant · Schéma : IMG-nicla-vision-debutant-1-niclavision-clignotement-led.svg — Nicla Vision vue de dessus avec les trois LED RGB surlignées et les broches LEDR, LEDG, LEDB

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials