Blinking an External LED
Now we'll use external components with the Pico 2 W. Let's start with something basic: blinking an LED connected to a GPIO pin.
Hardware Requirements
- ▸LED (any color)
- ▸330Ω Resistor
- ▸Jumper wires
- ▸Breadboard (optional but recommended)
Components Overview
LED (Light Emitting Diode)
An LED lights up when current flows through it. The longer leg (anode) connects to positive, and the shorter leg (cathode) connects to ground. We'll connect the anode to GPIO 13 (with a resistor) and the cathode to GND.
Resistor
A resistor limits the current in a circuit to protect components like LEDs. Its value is measured in Ohms (Ω). We'll use a 330Ω resistor to safely power the LED without burning it out.
Circuit Diagram
| Pico Pin | Wire | Component |
|---|---|---|
| GPIO 13 | → | Resistor (330Ω) |
| Resistor | → | LED Anode (long leg) |
| GND | → | LED Cathode (short leg) |

External LED connected to GPIO 13
On the Pico, the pin labels are on the back of the board, which can feel inconvenient when plugging in wires. Use the Raspberry Pi logo on the front as a reference point and match it with the pinout diagram to find the correct pins. Pin positions 2 and 39 are also printed on the front.
The Code
Create a new project with cargo-generate and select Embassy as the HAL. Then update the main function:
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
// Configure GPIO 13 as output, starting LOW (off)
let mut led = Output::new(p.PIN_13, Level::Low);
loop {
led.set_high(); // Turn on the LED
Timer::after_millis(500).await;
led.set_low(); // Turn off the LED
Timer::after_millis(500).await;
}
}We are using the Output struct because we want to send signals from the Pico to the LED. We set up GPIO 13 as an output pin and start it in the low (off) state.
Why GPIO 13? On the Pico 2 W, GPIO pins 23, 24, 25, and 29 are reserved for the wireless interface. GPIO 13 is a safe choice that doesn't interfere with WiFi or Bluetooth.
If you were using the standard Pico 2 (non-wireless), you could use GPIO 25 directly for an external LED since it's not reserved.
Required Imports
use embassy_executor::Spawner;
use embassy_rp::gpio::{Level, Output};
use embassy_time::Timer;Running the Program
# With BOOTSEL button
cargo run --release
# With debug probe
cargo flash --release
# or
cargo embed --releaseIf everything is wired correctly, you should see your external LED blinking on and off every 500 milliseconds.
Input vs Output
When to Use Each
Output
Use Output when you want to control something: turn LEDs on/off, drive motors, send signals to other devices. The Pico sends signals OUT.
Input
Use Input when you want to read signals: button presses, sensor values, signals from other devices. The Pico reads signals IN.