Built-in project · ESP32-C3 SuperMini

SuperMini blink

The blue LED on GPIO 8 lights when the pin is low and an LED on GPIO 2 when it is high, on the smallest ESP32-C3 board. The whole build, an ESP32-C3 SuperMini and 2 more parts, 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.

Teaching? Assign it to your class in one click.

Beginner About 10 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $8.15. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • Active-low versus active-high LEDs
  • Why the same blink needs opposite levels
  • LED_BUILTIN as a name for the board's LED
  • Timing with delay
  • Difficulty: Beginner
  • Time: About 10 minutes
  • Board: ESP32-C3 SuperMini
  • Parts: 4

How it works

This board has a blue LED on GPIO 8, wired from 3V3 through a resistor to the pin. So the pin must go LOW to light it. The LED you add on pin 2 is wired the usual way, from the pin through a 220 ohm resistor to GND, so it needs HIGH to light.

The sketch sets both together. Half a second with the blue LED lit and the red one lit, then half a second with both off. The two LEDs follow opposite pin levels, but they blink in step.

Parts list

4 parts, plus the jumper wires. They retail for about $8.15; on Mokxi they're free.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
LED, red pin CESP32-C3 SuperMini pin GND
Resistor, 220 Ω pin 1ESP32-C3 SuperMini pin 2
LED, red pin AResistor, 220 Ω pin 2

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-C3 SuperMini
// Blink, with an LED that is the other way round.
//
// The SuperMini's blue LED is on GPIO 8, so LED_BUILTIN is 8, the same number
// as on the DevKitM-1. The difference is the wiring: here the LED runs from
// 3V3 through a resistor to the pin, so the pin has to go LOW to light it.
// An LED you wire yourself from GPIO 2 to GND is the ordinary way round, so
// the two are always opposite.

const int WIRED = 2;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(WIRED, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, LOW);  // the blue LED on
  digitalWrite(WIRED, HIGH);       // the wired LED on
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);
  digitalWrite(WIRED, LOW);
  delay(500);
}

Code walkthrough

The key functions of the sketch, and what each one does.

setup sketch.ino

Makes both LED_BUILTIN (GPIO 8) and WIRED (pin 2) outputs using pinMode.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(WIRED, OUTPUT);
}

loop sketch.ino

Writes LOW to the built-in LED and HIGH to the wired one, and both light. After 500 ms with delay it flips both and waits another 500 ms. Opposite levels, same result.

void loop() {
  digitalWrite(LED_BUILTIN, LOW);  // the blue LED on
  digitalWrite(WIRED, HIGH);       // the wired LED on
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);
  digitalWrite(WIRED, LOW);
  delay(500);
}

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • The blue LED looks backward. This project
    It lights on LOW. That is normal for this board.
  • The red LED does not light. This project
    Check its direction. The anode (A) goes to the resistor from pin 2, and the cathode (C) to GND.
  • The LED is dim, burns out, or the pin reads wrong because the resistor value is off. Resistor
    Read the color bands again. A 220 ohm to 330 ohm resistor suits a typical LED on 5 V. 10k is a common pull-up or pull-down value. Check with a multimeter if unsure.
  • A pull-up or pull-down resistor is missing, so the input floats and reads random values. Resistor
    Tie the input to 5 V or ground through about 10k. Or use INPUT_PULLUP and wire the switch to ground.
  • The LED does not light, or it lights once and then dies. LED
    LEDs have polarity. The longer leg (anode) goes toward the positive side. Always add a series resistor, about 220 ohms to 1 k ohm on a 5 V pin.
  • A blue or white LED stays dark on 3.3 V. LED
    Blue and white LEDs drop about 3 V, so 3.3 V leaves almost nothing for the resistor. Use a 5 V supply, or a smaller resistor and a red or green LED.
  • The LED seems backwards. ESP32-C3 SuperMini
    The blue LED on GPIO8 lights when the pin is LOW, so digitalWrite LOW turns it on. Flip your blink logic, and remember the pin is also used by the boot setup.
  • Upload fails or no serial output. ESP32-C3 SuperMini
    Select the ESP32C3 Dev Module, and turn on USB CDC on boot to see Serial. If the port does not appear, hold the BOOT button while plugging in USB to enter download mode.

Change it and keep it

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