English
English
简体中文
日本語
pdf-icon

Arduino Quick Start

2. Devices & Examples

5. Extensions

6. Applications

Atom-Lite/Atom-Matrix RGB LED

APIs and an example sketch for the RGB LED on Atom-Lite / Atom-Matrix.

Example

Compilation Requirements

  • M5Stack Board Manager version >= 3.2.6
  • Development board option = M5Atom
  • M5Unified library version >= 0.2.8
  • M5GFX library version >= 0.2.11
  • Adafruit NeoPixel library version >= 1.15.1
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#include <M5Unified.h>
#include <Adafruit_NeoPixel.h>

#define LED_PIN 27
#define NUM_LEDS 25

Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
    M5.begin();
    Serial.begin(115200);
    Serial.printf("RGB LED Test\n");
    strip.begin();
}

void loop() {
    // Red
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(255, 0, 0)); }
    strip.show();
    delay(500);

    // Green
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(0, 255, 0)); }
    strip.show();
    delay(500);

    // Blue
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(0, 0, 255)); }
    strip.show();
    delay(500);

    // Yellow
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(255, 255, 0)); }
    strip.show();
    delay(500);

    // Magenta
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(255, 0, 255)); }
    strip.show();
    delay(500);

    // Cyan
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(0, 255, 255)); }
    strip.show();
    delay(500);

    // White (all on)
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(255, 255, 255)); }
    strip.show();
    delay(500);

    // Black (all off)
    for (char i = 0; i <= NUM_LEDS; i++) { strip.setPixelColor(i, strip.Color(0, 0, 0)); }
    strip.show();
    delay(500);
}

Running result:

API

The Atom-Lite/Atom-Matrix RGB LED uses the Adafruit NeoPixel library. For more information:

On This Page