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.

Here’s how the external LED is wired:
- GPIO4 (pin 4 on the ESP32) is connected to the anode (A) of the red LED via a red wire (
#e74c3c). - The cathode (C) of the red LED is connected to GND on the ESP32 via a dark wire (
#2c3e50).
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:


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

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:
- Line 5-6: We define two constants:
LED_BUILTIN_PINas2(the built-in LED pin) andLED_EXT_PINas4(the external LED pin). setup(): We start serial communication at 115200 baud, set both pins as outputs, and print a ready message.loop(): We turn both LEDs on (HIGH), print “LED ON”, wait 500 ms, turn both off (LOW), print “LED OFF”, and wait another 500 ms. This creates a continuous blink.
Key Concepts
- GPIO Pins: General Purpose Input/Output pins can be configured as inputs or outputs. Here we use them as outputs to drive LEDs.
pinMode(): Configures a pin asOUTPUTorINPUT.digitalWrite(): Sets a digital pin toHIGH(3.3V on ESP32) orLOW(0V).delay(): Pauses the program for a given number of milliseconds. This is a blocking delay — the microcontroller can’t do anything else during that time.- Built-in LED: Many development boards have an LED connected to a specific GPIO (often GPIO2 on ESP32). It’s a quick way to test your board.
Common Pitfalls & Debugging Tips
- Wrong pin number: Double-check that you’re using the correct GPIO number. The built-in LED is on GPIO2, not GPIO1 or GPIO0.
- LED polarity: LEDs have an anode (long leg, positive) and cathode (short leg, negative). In Velxio, the red LED component has pins labeled A (anode) and C (cathode). Make sure the anode connects to the GPIO and the cathode to GND.
- Missing ground: Both the ESP32 and the external LED must share a common ground. Our wire connects the LED cathode to GND.
- Serial Monitor: Use the Serial Monitor in Velxio to see the “LED ON” and “LED OFF” messages. If you don’t see them, check the baud rate (115200) and that you’ve opened the monitor.
- No blink?: Verify that the simulation is running (click the Run button in the toolbar). Also check that the code compiles without errors.
Suggested Extensions
Once you have the basic blink working, try these modifications:
- Change blink speed: Modify the
delay()values to make the LEDs blink faster or slower. - Blink only one LED: Comment out one of the
digitalWritecalls to blink only the built-in or only the external LED. - Add a third LED: Place another LED on GPIO5 and wire it up. Update the code to blink all three in sequence.
- Use PWM for fading: Instead of
digitalWrite, useanalogWrite()to fade the LED brightness (ESP32 supports PWM on most pins). - 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!