ESP32 C3 Super Mini - LED - Blink Without Delay
The simplest way to blink an LED is the delay() function, but it stops the ESP32 C3 Super Mini from doing anything else. That is fine for a single LED, but not when you want to blink more LEDs or do other work at the same time. This tutorial shows how to blink an LED without delay on the ESP32 C3 Super Mini while it also checks a button.
In this tutorial, you'll learn:
- Why delay() blocks the ESP32 C3 Super Mini from doing other tasks
- How to wire an LED and a button to the ESP32 C3 Super Mini
- How to blink an LED without delay by using millis()
- How to compare the two methods with a simple button test
- How to blink two LEDs at different speeds and still read a button

We will run through these examples and compare them:
- Example 1: ESP32 C3 Super Mini blinks an LED by using the delay() function
- Example 2: ESP32 C3 Super Mini blinks an LED by using the millis() function
- Example 3: ESP32 C3 Super Mini blinks two LEDs at different speeds by using millis()
- Easier Option: The ezLED library manages the timing for you, once you understand the idea
This method lets the ESP32 C3 Super Mini do several tasks at the same time. Blinking an LED is just an example.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: Use the LED Module for easier wiring. It includes an integrated resistor.
Wiring Diagram
Connect the LED and the button to your ESP32 C3 Super Mini as shown below.
- Note: Always use the 220 ohm resistor with the LED to protect it from damage.
- Note: The button needs no external resistor, because the code turns on the internal pull-up resistor on GPIO5.

This image is created using Fritzing. Click to enlarge image
If you do not use a breadboard, wire it like this:

This image is created using Fritzing. Click to enlarge image
| Component Pin | ESP32 C3 Super Mini Pin |
|---|---|
| LED anode (long leg), through the 220 ohm resistor | GPIO7 |
| LED cathode (short leg) | GND |
| Button pin 1 | GPIO5 |
| Button pin 2 | GND |
Let's compare the ESP32 C3 Super Mini code that blinks an LED with and without the delay() function
ESP32 C3 Super Mini Code - With Delay
This first code blinks the LED with delay(), so you can see the problem for yourself.
What This Code Does:
- Blinks the LED: Toggles the LED on GPIO7 every 1000 milliseconds
- Waits: Stops on delay() for the whole second
- Reads the Button: Checks GPIO5 only once per second, after each delay
- Prints Changes: Sends the button state to the Serial Monitor when it changes
Detailed Instructions
- New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Super Mini tutorial first to set up your development environment.
- Wire the Circuit: Connect the components as shown in the diagram above.
- Connect the Board: Plug the ESP32 C3 Super Mini into your computer with a USB Type-C cable.
- Open Arduino IDE: Launch the Arduino IDE on your computer.
- Select Board: Make sure ESP32 C3 Super Mini is selected in Tools > Board, then choose its COM port.
- Copy Code: Copy the code above and paste it into the Arduino IDE.
- Upload Code: Click the Upload button to compile and upload the code.

- Open Serial Monitor: Open the Serial Monitor and set the baud rate to 115200.

- Press the Button: Press the button quickly 4 times.
- Watch the LED: The LED toggles between ON and OFF every second.
- Check the Output: See the result in the Serial Monitor.
- What It Means: 1 means released and 0 means pressed. You will not see 0 four times, because the ESP32 C3 Super Mini CANNOT detect a press during the delay time.
- Pro Tip: Try longer delays. The longer the delay, the more button presses are missed.
ESP32 C3 Super Mini Code - Without Delay
This code blinks the LED at the same speed, but it never stops to wait.
What This Code Does:
- Checks the Time: Reads millis() on every loop instead of waiting
- Blinks on Time: Toggles the LED on GPIO7 only when 1000 milliseconds have passed
- Reads the Button: Checks GPIO5 on every loop, thousands of times per second
- Stays Free: Leaves room for other work in loop()
Detailed Instructions
- New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Super Mini tutorial first to set up your development environment.
- Select Board: Make sure ESP32 C3 Super Mini is selected in Tools > Board.
- Upload Code: Run the code above on your board.
- Open Serial Monitor: Keep the baud rate at 115200.
- Press the Button: Press the button 4 times.
- Watch the LED: The LED still toggles between ON and OFF every second.
- Check the Output: See the result in the Serial Monitor.
- What It Means: All 4 presses were detected. The first 1 is the released state when the code starts.
- Pro Tip: If the Serial Monitor stays blank, set USB CDC On Boot to Enabled in the Tools menu and upload again.
Line-by-line Code Explanation
The ESP32 C3 Super Mini code above has a line-by-line explanation in its comments. Please read them!
Adding More Tasks
This code blinks two LEDs at different speeds and also checks the state of the button.
What This Code Does:
- LED 1: Blinks on GPIO6, toggling every 1000 milliseconds
- LED 2: Blinks on GPIO7, toggling every 500 milliseconds
- Separate Timers: Keeps one millis() time for each LED
- Button: Still reads GPIO5 on every loop and prints each change
Add the second LED to the same circuit. It needs one more LED and one more 220 ohm resistor.
| Component Pin | ESP32 C3 Super Mini Pin |
|---|---|
| LED 1 anode (long leg), through a 220 ohm resistor | GPIO6 |
| LED 1 cathode (short leg) | GND |
| LED 2 anode (long leg), through a 220 ohm resistor | GPIO7 |
| LED 2 cathode (short leg) | GND |
| Button pin 1 | GPIO5 |
| Button pin 2 | GND |
Detailed Instructions
- New to ESP32 C3 Super Mini? Complete our Getting Started with ESP32 C3 Super Mini tutorial first to set up your development environment.
- Select Board: Make sure ESP32 C3 Super Mini is selected in Tools > Board.
- Upload Code: Run the code above on your board.
- Open Serial Monitor: Keep the baud rate at 115200.
- Watch the LEDs: LED 2 blinks twice as fast as LED 1.
- Press the Button: Each press and release appears in the Serial Monitor, while both LEDs keep their speed.
- Pro Tip: Change BLINK_INTERVAL_1 and BLINK_INTERVAL_2 to set a different speed for each LED.
Application and Project Ideas
Blinking without delay on the ESP32 C3 Super Mini helps any project that must do many things at once.
- Status Light: Blink a "working" LED while the board reads sensors
- Alarm Panel: Flash a warning LED and still react to a stop button at once
- Traffic Light: Run timed light changes while watching a crossing button
- Plant Monitor: Blink an LED when the soil is dry, and keep taking readings
- Smart Device: Show the connection state with an LED while WiFi code keeps running
Challenge Yourself
Try these challenges to practice non-blocking code on your ESP32 C3 Super Mini.
- Easy: Change BLINK_INTERVAL to make the LED blink faster or slower
- Easy: Print a message to the Serial Monitor each time the LED changes state
- Medium: Make the button change the blink speed between slow and fast
- Medium: Add a third LED with its own interval and its own timer
- Advanced: Make the LED stay ON for 200 milliseconds and OFF for 800 milliseconds
- Advanced: Rewrite the two-LED code with the ezLED library and compare the code