How to Simulate LED Blinking with Raspberry Pi Pico in Wokwi: Step-by-Step Tutorial

What is Wokwi?

Wokwi is a free online electronics simulator that lets you test Raspberry Pi Pico projects in your web browser without any physical hardware. Perfect for learning, prototyping, and debugging!

Getting Started with Wokwi

Step 1: Access Wokwi Simulator

  • Open your web browser
  • Go to https://wokwi.com
  • Click "Start from Scratch" or "New Project"
  • Select "Raspberry Pi Pico" from the board options


Step 2: Add Components to Your Simulation

Diagram .json:
{
  "version": 1,
  "author": "Anonymous maker",
  "editor": "wokwi",
  "parts": [
    {
      "type": "wokwi-pi-pico",
      "id": "pico",
      "top": 0,
      "left": 0,
      "rotate": 0,
      "hide": false,
      "attrs": {}
    },
    {
      "type": "wokwi-led",
      "id": "led1",
      "top": -2.67,
      "left": -65.33,
      "rotate": 0,
      "hide": false,
      "attrs": { "color": "red" }
    }
  ],
  "connections": [
    [ "pico:GP5", "led1:A", "green", [ "h0" ] ],
    [ "pico:GND.2", "led1:C", "black", [ "h0" ] ]
  ]
}

Add an LED:

  • Click the blue "+" button in the parts panel
  • Search for "LED"
  • Click to add it to your workspace
  • The LED will appear on your canvas

Add a Resistor:

  • Click the "+" button again
  • Search for "Resistor"
  • Select a 220Ω or 330Ω resistor
  • Add it to your workspace

Step 3: Position Your Components

  • Drag the LED near your Raspberry Pi Pico board
  • Position the resistor between the LED and the Pico
  • Arrange them similar to the diagram shown in your image

Step 4: Wire the Circuit

Connect the Resistor to LED:

  • Click on one end of the resistor
  • Drag a wire to the positive (anode) leg of the LED
  • In Wokwi, the LED's anode is typically the left pin when oriented upright

Connect Resistor to GPIO Pin:

  • Click the other end of the resistor
  • Drag a wire to GP15 (GPIO pin 15) on the Pico
  • The pin labels are visible when you hover over them

Connect LED to Ground:

  • Click the negative (cathode) leg of the LED
  • Drag a wire to any GND pin on the Pico
  • Ground pins are labeled "GND" on the board

Step 5: Write Your Code in Wokwi

Click on the code editor section and enter this MicroPython code:

from machine import Pin
from utime import sleep

sleep(0.01) # Wait for USB to connect
print("Hello, Pi Pico!")

led = Pin(5, Pin.OUT)
while True:
  led.toggle()
  sleep(0.5)


Comments