Example Code for Arduino - Native GPIO pins of ESP32-S3

Last revision 2026/02/05

Function Description

The DMX512 controller features two GPIOs, IO4 and IO5, supporting digital input/output and analog input. They can be used for connecting digital sensors, driving two servos, two analog inputs, or driving WS2812 LED strips, among other applications. Its usage is identical to the conventional ESP32.
Native GPIO pins of ESP32-S3

Example: Music Spectrum Light

Wiring diagram

Wiring diagram
The following code demonstrates using IO4 to connect an analog sound level meter module and driving the number of RGB light strips with the sound intensity, creating a simple music spectrum light effect.

#include "DFRobot_DMX512.h"

DFRobot_DMX512 dmx512;

void setup() { 
    Serial.begin(115200);  
    while(dmx512.begin() != 0){   //Initialize DMX512.
        Serial.println("init error");
        delay(1000);
    }
    Serial.println("init OK");     
}

void loop() {
    int datasound = analogRead(4);
    Serial.println(datasound);
    int leddata = map(datasound, 1000, 2500, 0, 8);
    dmx512.RGBLight(1,leddata,0,0,255);
    delay(30);
    dmx512.RGBLight(leddata*3+1,8,0,0,0);
    delay(30);
}

Was this article helpful?

ON THIS PAGE

TOP