pdf-icon

Arduino Guide

RGB LED

StamPLC status light related APIs and example program.

Example Program

/*
 *SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
 *
 *SPDX-License-Identifier: MIT
 */
#include <Arduino.h>
#include <M5StamPLC.h>

void setup()
{
    /* Init M5StamPLC */
    M5StamPLC.begin();
}

void loop()
{
    /* Set status light to red */
    M5StamPLC.setStatusLight(1, 0, 0);
    printf("Set status light to red\n");
    delay(1000);

    /* Set status light to green */
    M5StamPLC.setStatusLight(0, 1, 0);
    printf("Set status light to green\n");
    delay(1000);

    /* Set status light to blue */
    M5StamPLC.setStatusLight(0, 0, 1);
    printf("Set status light to blue\n");
    delay(1000);

    /* Set status light to white */
    M5StamPLC.setStatusLight(1, 1, 1);
    printf("Set status light to white\n");
    delay(1000);

    /* Set status light to black */
    M5StamPLC.setStatusLight(0, 0, 0);
    printf("Set status light to black\n");
    delay(1000);
}

API

setStatusLight

Function Prototype:

void setStatusLight(const uint8_t& r, const uint8_t& g, const uint8_t& b);

Function Description:

  • Sets the RGB LED color. Note that the RGB LED is driven by the IO expansion chip's pins, so brightness adjustment is not supported.

Parameters:

  • const uint8_t& r:
    • 1: Turn on the red light
    • 0: Turn off the red light
  • const uint8_t& g:
    • 1: Turn on the green light
    • 0: Turn off the green light
  • const uint8_t& b:
    • 1: Turn on the blue light
    • 0: Turn off the blue light

Return Value:

  • null
On This Page