Software/Arduino Core/Basics

LEDs and the Button

The on-board RGB LED, the RGB helper object, the USER button, and the LED states the core uses for its own signalling.

beginner2 min read

The Neuro N6 has one RGB LED and one user button accessible from a sketch. Both are configured by the core before setup() runs.

RGB LED

The LED is three discrete elements in one package, common anode to 3.3 V. Each channel is a GPIO output and is active low.

ConstantChannelMCU pin
LEDRRedPE11
LEDGGreenPD6
LEDBBluePC1
LED_BUILTINAlias of LEDG
cpp
pinMode(LEDB, OUTPUT);
digitalWrite(LEDB, LOW);    // on
digitalWrite(LEDB, HIGH);   // off

All three channels accept analogWrite. A value of 0 is fully on and 255 is off.

RGB object

The RGB object, provided by Arduino.h, sets all three channels at once and handles the polarity.

cpp
void loop() {
  RGB.red();     delay(500);
  RGB.yellow();  delay(500);
  RGB.green();   delay(500);
  RGB.cyan();    delay(500);
  RGB.blue();    delay(500);
  RGB.magenta(); delay(500);
  RGB.white();   delay(500);
  RGB.off();     delay(500);
}

RGB.set(r, g, b) takes three booleans, true meaning lit. RGB.begin() is optional. The RgbLed example cycles the same table.

Core status indications

The core uses the LED for status until a sketch writes to it.

IndicationMeaning
Purple (red and blue) at bootThe application is running. The power save library turns this off, as the LED draws tens of milliamps
Slow red pulseThe board is in bootloader mode
Solid red shortly after power upThe firmware entered its error handler. The serial port prints an [ERRDUMP] block with fault registers and the failing address
Red blinking n times at bootWith the power save library linked, the previous run failed inside the sleep engine at step n

USER button

BTN_USER is on PG8 with an external 10k pull-down. It reads HIGH while pressed.

cpp
void setup() {
  Serial.begin(115200);
  pinMode(BTN_USER, INPUT);
}

void loop() {
  Serial.println(digitalRead(BTN_USER) ? "pressed" : "released");
  delay(100);
}

Presses can be counted with an interrupt on the rising edge:

cpp
volatile unsigned long presses = 0;

void onPress() { presses++; }

void setup() {
  pinMode(BTN_USER, INPUT);
  attachInterrupt(digitalPinToInterrupt(BTN_USER), onPress, RISING);
}

The button is not debounced in hardware. A mechanical press produces a burst of edges over several milliseconds; an exact counter ignores edges within about 20 ms of the previous one.

USER_BTN is an alias of BTN_USER.

Reset button

The reset button is not readable from a sketch. Two presses less than 900 ms apart place the board in the DFU bootloader, which is the recovery route for an application that no longer accepts uploads. The RGB LED pulses red while the bootloader is active.

Charging status LED

A second LED, red, shows the battery charger state and is not programmable: on while charging, flashing at 20 Hz when USB is connected with no battery, off when charging is complete or USB is absent. See First Upload.

Strobe LED

Camera carriers with a flash LED connect it to the sensor's strobe output rather than to a GPIO. It pulses in synchrony with each frame's exposure and is controlled by cfg.strobe in VisionConfig or camera.setStrobe(). It cannot be held on continuously from a sketch.