Built-in project · ESP32-S3-DevKitC-1

ESP32-S3 rainbow

The DevKitC-1’s own RGB LED walking around the color wheel, one WS2812 frame from the RMT every 20 ms. The whole build, an ESP32-S3-DevKitC-1, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Runs in your browser. Free, and no account needed.

ESP32-S3 rainbow · ESP32-S3-DevKitC-1live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · ESP32-S3-DevKitC-1
// Rainbow: the RGB LED on GPIO48 walks round the color wheel.
//
// rgbLedWrite(pin, red, green, blue) sends one WS2812 frame on RMT channel 0:
// twenty-four bits, green first, each a high pulse of 400 or 800 ns. The
// color holds until the next frame, so the sketch only has to send one
// every few milliseconds.

const int kLed = RGB_BUILTIN;

// One step round the wheel: 0..255 in, a color out, at full brightness / 4.
void wheel(int pos, int *r, int *g, int *b)
{
    pos = pos & 255;
    if (pos < 85) {
        *r = 255 - pos * 3;
        *g = pos * 3;
        *b = 0;
    } else if (pos < 170) {
        pos -= 85;
        *r = 0;
        *g = 255 - pos * 3;
        *b = pos * 3;
    } else {
        pos -= 170;
        *r = pos * 3;
        *g = 0;
        *b = 255 - pos * 3;
    }
    *r /= 4;
    *g /= 4;
    *b /= 4;
}

void setup()
{
    Serial.begin(115200);
    Serial.println("rainbow on the RGB LED, GPIO48");
}

void loop()
{
    for (int pos = 0; pos < 256; pos += 4) {
        int r, g, b;
        wheel(pos, &r, &g, &b);
        rgbLedWrite(kLed, r, g, b);
        delay(20);
    }
}

Parts list

2 parts, plus the jumper wires. Every one is in the editor's parts bin.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.