pdf-icon

Arduino Quick Start

StamPLC RGB LED

StamPLC status light related APIs and example program.

Example Program

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
/*
*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