Go back

ESP32 Blink LED: Your First Velxio Simulation

Welcome to your first Velxio simulation! In this tutorial, we’ll blink the built-in blue LED on an ESP32 DevKit (GPIO2) and an external red LED connected to GPIO4. This is the “Hello World” of microcontrollers — a simple project that verifies your ESP32 emulation is working correctly.

Circuit Walkthrough

Let’s look at the circuit. The ESP32 DevKit is the brain of our project. It has a built-in blue LED already connected to GPIO2, so we don’t need to wire that one. For the external LED, we add a red LED component from the component picker.

Circuit diagram of esp32-blink-led on the Velxio simulator canvas

Here’s how the external LED is wired:

That’s it! Only two wires for the external LED. The built-in LED is already on the board.

To add components and wires, use the Velxio editor toolbar and canvas toolbar:

Velxio editor toolbar with compile and run controls

Velxio canvas toolbar above the simulation viewport

To browse and place parts like the red LED, open the component picker:

Velxio component picker modal browsing parts by category

Code Walkthrough

Now let’s examine the code. Open the code editor in Velxio — you’ll see the following Arduino sketch:

// ESP32 Blink LED
// Blinks the built-in LED (GPIO2) and an external LED (GPIO4)
// Requires arduino-esp32 2.0.17 (IDF 4.4.x) — see docs/ESP32_EMULATION.md


#define LED_BUILTIN_PIN 2   // Built-in blue LED on ESP32 DevKit
#define LED_EXT_PIN     4   // External red LED


void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN_PIN, OUTPUT);
  pinMode(LED_EXT_PIN, OUTPUT);
  Serial.println("ESP32 Blink ready!");
}

void loop() {
  digitalWrite(LED_BUILTIN_PIN, HIGH);
  digitalWrite(LED_EXT_PIN, HIGH);
  Serial.println("LED ON");
  delay(500);

  digitalWrite(LED_BUILTIN_PIN, LOW);
  digitalWrite(LED_EXT_PIN, LOW);
  Serial.println("LED OFF");
  delay(500);
}

Let’s break it down:

Key Concepts

Common Pitfalls & Debugging Tips

Suggested Extensions

Once you have the basic blink working, try these modifications:

  1. Change blink speed: Modify the delay() values to make the LEDs blink faster or slower.
  2. Blink only one LED: Comment out one of the digitalWrite calls to blink only the built-in or only the external LED.
  3. Add a third LED: Place another LED on GPIO5 and wire it up. Update the code to blink all three in sequence.
  4. Use PWM for fading: Instead of digitalWrite, use analogWrite() to fade the LED brightness (ESP32 supports PWM on most pins).
  5. Add a button: Connect a push button to an input pin and make the LED turn on only when the button is pressed.

Try It Yourself!

Ready to blink? Open the live example in Velxio and start the simulation. You’ll see both LEDs flashing in sync. Experiment with the code and circuit — it’s the best way to learn.

Open the ESP32 Blink LED example on Velxio

Happy blinking!


Share this post on:
David Montero

Written by

David Montero

Creator of Velxio, the open-source circuit and Arduino simulator.

GitHub velxio.dev

Related posts


Previous Post
Seeed Studio hardware comes to Velxio: XIAO boards, the Round Display, Grove and ReSpeaker in your browser
Next Post
Velxio vs Wokwi, Tinkercad, Proteus and Fritzing: an honest comparison