Skip to main content

Led Controller

note

For an API reference, see API Reference/Led Control

The LED module provides an interface to control the five on-board LEDs. Namely CELL, CON, DATA, ERROR and USER.

To use the LED Controller, it must be initialized with either normal mode or manual mode.

  • Normal Mode: All LEDs except for the USER LED can be controlled by the system to reflect its state. For instance, the CELL LED turns on when connected to the network.
    • Initialied with LedCtrl.begin()
  • Manual Mode: No LEDs are controlled by the system, and must be manually set by the user.
    • Initialized with LedCtrl.beginManual()

Example

#include <led_ctrl.h>

void setup() {
// Initialize the Led Controller in normal mode
LedCtrl.begin();

// Perform a startup "animation" with the LEDs
LedCtrl.startupCycle();

// Turn on the User LED
LedCtrl.on(Led::USER);

delay(1000);

// Turn off the User LED
LedCtrl.off(Led::USER);

// Toggle the Error LED
LedCtrl.toggle(Led::ERROR);
}

Controlling the LEDs

Leds can be controlled through four calls

  • LedCtrl.on(LED)
  • LedCtrl.off(LED)
  • LedCtrl.toggle(LED)
  • LedCtrl.startupCycle()

The LED argument can be Led::CELL, Led::CON, Led::DATA, Led::ERROR and Led::USER.

Example (Interactive)

This example initializes the led controller and runs a "LED animation". The USER led is turned on. The ERROR and CELL LED blink every second.

Use the interactive code editor to compile a hex file that you can program onto your board.

Live Editor

Live Editor
#include <Arduino.h>
#include <led_ctrl.h>
void setup(){
LedCtrl.begin();
LedCtrl.startupCycle();
LedCtrl.on(Led::USER);
}
void loop(){
LedCtrl.toggle(Led::ERROR);
LedCtrl.toggle(Led::CELL);
delay(1000);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
No action performed