ESP ZeroCode AI · Community

Wiring diagram for Blink Led

Blink Led

Can you create an example sketch for me using only the onboard LED on an ESP32-C3 (ESP32-C3 DevKitM-1 / ESP32-C3 v1 board)? I want the onboard LED to have multiple modes, and I want to switch between modes by pressing the onboard BOOT/RST button — no external components needed. The modes should be: Rainbow (color cycling — note: only works if the onboard LED is an addressable RGB LED like WS2812) Blink Fast blink Slow blink Flashlight (steady on) Each press of the button should cycle to the next mode, and the onboard LED should follow the currently selected mode

ESP32-C3
Download the firmware Open-source licences Fork it in the studio

What it does

Manual

Device Type
summary: An ESP32-C3-DevKitM-1 lighting demo: six scenes played on the board's own addressable RGB LED plus a chain of 5 external WS2812 LEDs, switched by a button. — problem: A one-button light-scene player with a bigger, brighter 5-pixel display — rainbow, three blink speeds, flash and a running 'following' chase — with no network, app or extra controller.

Hardware
chip: esp32c3 — board: esp32-c3-devkitm-1 — boardNote: ESP32-C3-DevKitM-1 (ESP32-C3-MINI-1 module). Its own WS2812 (GPIO 8) and BOOT button (GPIO 9) are used as-is; the 5-LED chain and second button are the only externally wired parts. — gpios: gpio: GPIO8 — function: WS2812 data to the on-board RGB LED (already on the board) · gpio: GPIO9 — function: On-board BOOT button, active-low, board pull-up; doubling as a scene button · gpio: GPIO4 — function: WS2812 data to the external 5-LED chain · gpio: GPIO5 — function: External push button, active-low with the internal pull-up — peripherals: part: WS2812B addressable RGB LED — placement: on-board — pins: DIN ← GPIO8, VCC ← 3V3, GND — notes: One pixel. Dark during the chase scene, mirrors the 5-LED chain otherwise. · part: 5 × WS2812B addressable RGB LEDs — placement: external, wired by the user — pins: first LED DIN ← GPIO4, VCC ← board 5V pin, GND ← board GND — notes: Wired as a daisy chain (DOUT → DIN) so all five are driven from one GPIO. 3.3 V data into the first LED is fine at 5 V supply. Pixels addressed 0..4 in chain order. Keep the 5 V supply's current draw in mind: full white on 5 pixels is roughly 250 mA, inside the DevKitM-1's USB supply. · part: External momentary push button — placement: external, wired by the user — pins: GPIO5 ↔ GND — notes: No external resistor needed — uses the chip's internal pull-up; idle high, pressed low. · part: BOOT push button — placement: on-board — pins: GPIO9 ↔ GND (active low) — notes: Same function as the external button. Holding it while powering on or resetting still enters serial-boot mode — expected, and how the board is flashed.

Inputs
kind: button — label: Scene button (on-board BOOT button, GPIO 9) — hardware: GPIO9, active-low, board pull-up — behavior: A debounced press (~50 ms) advances to the next scene and wraps from chase back to rainbow. The new scene starts on release; no acknowledgement blink. A long press is simply one advance — special meaning: none. · kind: button — label: Scene button (external push button, GPIO 5) — hardware: GPIO5, active-low, internal pull-up — behavior: Identical to the on-board button — either works, pressing both at once still counts as one advance. This lets the light be switched from wherever the user mounted the external button.

Outputs
kind: rgb-leds — label: On-board RGB LED + 5 external WS2812 LEDs — hardware: Two independent WS2812 channels: 1 pixel on GPIO8, 5 pixels on GPIO4 — behavior: Exactly one scene runs at a time, looping until the button changes it or power is removed.

Business Logic
powerOnBehavior: On every boot the saved scene is read and starts immediately on both outputs (on-board LED and the 5-LED chain). With nothing saved (factory-fresh) scene 1 (rainbow) is used and written. — dayToDayOperation: Set and forget: the LED chain animates on its own, either button steps to the next scene, and the choice is saved to NVS immediately so unplugging never loses it. — persistence: One NVS value holds the scene index (1–6); it is written only on a scene change, so normal running does not wear the flash. — noNetwork: No Wi-Fi, MQTT, cloud or app; nothing depends on time of day, so there is no timezone.

Factory Reset
trigger: Serial console command `factory_reset` over USB (no button combo — both buttons are scene switches). — effect: Erases the saved scene and reboots; the device comes up in rainbow. — feedback: Because there is no acknowledgement flash, the return is visible as the rainbow starting on both outputs.

Failure Modes
scenario: Power removed / brown-out — behavior: Reboots into the last saved scene; both outputs resume. · scenario: BOOT button held while powering on or resetting — behavior: Chip enters serial download mode, LEDs stay dark; release and power-cycle to resume. Normal, and how firmware is flashed. · scenario: External LED chain disconnected or miswired — behavior: The on-board LED keeps running its scene and both buttons keep working; the external chain simply stays dark. · scenario: External button not wired — behavior: GPIO5 reads idle-high all the time — no false presses; the on-board button alone still switches scenes. · scenario: WS2812 driver fails to initialise — behavior: Firmware keeps running so the buttons still change scenes; the fault is logged to the console and whichever output initialised still animates. · scenario: Saved value corrupt or out of range — behavior: Falls back to scene 1 (rainbow) and rewrites it.

Power Management
batteryPowered: false — notes: USB powered only. No sleep — the animation is the point of the product. Five WS2812s at full brightness draw roughly 250 mA, which the board's USB supply covers.

Custom Behavior
notes: Scene order (rainbow → blink → fast blink → slow blink → flash → chase, wrapping) is the user-visible contract, as is the chase rule: one pixel, 150 ms per step, hue advancing per step, on-board LED dark.

Published 18 Nov 2026
Firmware and source licensed Apache-2.0; photos and text CC-BY-4.0.
The firmware includes open-source software — open-source licences and notices; some components may be used only with Espressif chips.
Built with ESP ZeroCode AI — describe a device, get production firmware.
Terms of Service · Privacy Policy