Go back

Blink an LED on Raspberry Pi Pico with Velxio Simulator

Introduction

Welcome to the world of microcontrollers! The classic “Blink” example is the perfect starting point for any embedded systems journey. In this tutorial, we’ll use the Raspberry Pi Pico and its built-in LED on GPIO 25 to create a simple blinking pattern. The best part? You don’t need any hardware — we’ll run everything in the Velxio in-browser simulator, which provides SPICE-accurate analog simulation and a full-featured code editor.

By the end of this post, you’ll understand how to set up a basic circuit, write Arduino-compatible code, and simulate it live. Let’s dive in!

Circuit Walkthrough

Circuit diagram of pico-blink on the Velxio simulator canvas

The circuit is minimal — perfect for beginners. Here’s what we have:

Wiring Details

  1. GPIO D2 on the Pico connects to the anode (A) of the LED via a green wire (#00cc00).
  2. The cathode (C) of the LED connects to one leg of the 220 Ω resistor via a grey wire (#999999).
  3. The other leg of the resistor connects to GND.1 on the Pico via a black wire (#000000).

Note: The built-in LED on the Pico is connected to GPIO 25, but in this example we use an external LED on GPIO D2 to demonstrate wiring. You can easily modify the code to use the onboard LED by changing the pin to LED_BUILTIN.

Component Values

ComponentValue / ID
LEDled-blink (green)
Resistorr1 (220 Ω)
Pico pinD2 (GPIO 2)
Pico GNDGND.1

Code Walkthrough

Here’s the complete Arduino sketch for the Pico:

// Raspberry Pi Pico — Blink LED
// Toggles the onboard LED on GPIO 25

void setup() {
  pinMode(LED_BUILTIN, OUTPUT); // GPIO 25
  Serial.begin(115200);
  Serial.println("Pico Blink Example");
}

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

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

Code Breakdown

Important: The code uses LED_BUILTIN which is predefined for the Pico as GPIO 25. If you want to use the external LED on D2, change LED_BUILTIN to 2.

Key Concepts for Students

  1. Digital Output: pinMode() configures a pin as output; digitalWrite() sets it HIGH (3.3V) or LOW (0V).
  2. Built-in LED: Many boards have an LED connected to a specific pin (GPIO 25 for Pico). Using LED_BUILTIN makes code portable.
  3. Serial Monitor: Serial.println() sends data to the serial port, viewable in the simulator’s serial monitor. It’s invaluable for debugging.
  4. Delay: delay(ms) pauses the program. Be careful — it blocks other operations.

Common Pitfalls & Debugging Tips

Velxio editor toolbar with compile and run controls

Velxio canvas toolbar above the simulation viewport

Suggested Extensions

Once you’ve mastered the basic blink, try these modifications:

  1. Change blink speed: Adjust the delay() values to make it faster or slower.
  2. Use the external LED: Modify the code to use pin 2 instead of LED_BUILTIN.
  3. Add a button: Use a digital input to turn the LED on/off when pressed.
  4. Fade with PWM: Use analogWrite() to create a breathing effect.
  5. Multiple LEDs: Add more LEDs on different pins and create patterns.

Get Started with Velxio

Ready to build your own circuits? Velxio makes it easy to design, code, and simulate electronics projects right in your browser — no downloads or hardware required. The component picker lets you browse hundreds of parts.

Velxio component picker modal browsing parts by category

Try the live example now: Pico Blink 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
Pico Serial Echo: Test UART on RP2040 with Velxio
Next Post
Master Serial, I2C, and SPI on Arduino with Velxio