Built-in project · ESP32-C3-DevKitM-1

ESP32-C3 button

A pushbutton from GPIO 9 to GND, with the internal pull-up, lights the LED on GPIO 8 while it is held. The whole build, an ESP32-C3 and 3 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.

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

ESP32-C3 button · ESP32-C3-DevKitM-1live0.000 s 0.00x
Hold the button
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-C3-DevKitM-1
// Button: a pushbutton on GPIO 9 lights the LED on GPIO 8.
//
// INPUT_PULLUP switches on the pad's 45 k pull-up, so the pin sits at 3.3 V
// until the button pulls it to GND. That is why the button reads LOW when it
// is pressed: wire one side to GPIO 9 and the other to GND, no resistor.

const int BUTTON_PIN = 9;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  bool pressed = digitalRead(BUTTON_PIN) == LOW;
  digitalWrite(LED_BUILTIN, pressed ? HIGH : LOW);
  delay(5);
}

Parts list

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

How it is wired

4 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Ground: ESP32-C3-DevKitM-1 pin GND; LED, red pin C; Pushbutton pin 2a
  • ESP32-C3-DevKitM-1 pin 8; Resistor, 220 Ω pin 1
  • ESP32-C3-DevKitM-1 pin 9; Pushbutton pin 1b
  • Resistor, 220 Ω pin 2; LED, red pin A

Change it and keep it

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