ESP32: blink and fade
The blue LED on GPIO 2 blinks; an LED on GPIO 4 fades with LEDC PWM.

The code
// ESP32: the blue LED on GPIO 2 blinks, and an LED on GPIO 4 fades with LEDC PWM.
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
ledcAttach(4, 5000, 8);
Serial.printf("ESP32 ready at %lu MHz\n", getCpuFrequencyMhz());
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
for (int d = 0; d <= 255; d += 5) {
ledcWrite(4, d);
delay(10);
}
digitalWrite(LED_BUILTIN, LOW);
for (int d = 255; d >= 0; d -= 5) {
ledcWrite(4, d);
delay(10);
}
Serial.printf("uptime %lu ms\n", millis());
}
More like this

ESP32-S3: RGB LED
The S3 DevKitC-1’s own RGB LED (GPIO48) through the colours with rgbLedWrite().
ArduinoESP32-S3 DevKitC-1

ESP32-C3: button and RGB LED
A button on GPIO 4 steps the C3 DevKitM-1’s RGB LED through colours.
ArduinoESP32-C3 DevKitM-1

Web switch on a hotspot
The ESP32 starts its own Wi-Fi (softAP) and serves a page with ON and OFF buttons for an LED. Join it from the phone.
ArduinoESP32 DevKit V1