
Arduino Quick Start
Unit PoE-P4 RGB LED example.
#include "M5Unified.h"
void setRGB(uint8_t r, uint8_t g, uint8_t b){
uint8_t red = ~r;
uint8_t green = ~g;
uint8_t blue = ~b;
analogWrite(17, red);
analogWrite(15, green);
analogWrite(16, blue);
}
void setup() {
M5.begin();
pinMode(15, OUTPUT);
analogWriteResolution(15, 8);
pinMode(16, OUTPUT);
analogWriteResolution(16, 8);
pinMode(17, OUTPUT);
analogWriteResolution(17, 8);
}
void loop() {
setRGB(255, 0, 0);// red
delay(2000);
setRGB(0, 255, 0);// green
delay(2000);
setRGB(0, 0, 255);// blue
delay(2000);
}The RGB LED on the Unit PoE-P4 is wired to GPIO pins 15, 16 and 17, and uses a common‑anode design. The example code inverts the colour values before writing them out; the sketch cycles through red, green and blue, holding each colour for two seconds.