Blinking a led on the Raspberry Pi Pico W

July 21st, 2022

One much requested feature has landed to the Raspberry Pi Pico, and that is connection, Wifi and in the future Bluetooth are added, and that new Raspberry Pi Pico W just landed in my postbox.

Blinking a led is the first thing most lads try out, a bit like printing “Hello World” in any new program language.

The official documentation gives this example

from machine import Pin
led = Pin(25, Pin.OUT)
led.value(1) // led on
led.value(0) // led off

I blinked my eye twice, but running this code the Pico W did not light its led.

How to blink a led on the Raspberry Pi Pico W

I did remember reading about a change in GPIO pins, because the Wifi-modules needed some for connection, but I was surprised it was not mentioned in the official Raspberry Pi Pico documentation.

Actually with the introduction of the Wifi variant there are changes made in the micropython framework, to let the same code blink a led on any Raspberry Pi Pico, they gave the needed pin a name; “LED”, and added two functions, on and off.

from machine import Pin
led = Pin("LED", Pin.OUT)
led.on()  // a method instead of setting the value // turn it off again.

Do remember you need to download a different firmware for the Pico and the Pico W.

RPI Pico firmware link

RPI Pico W (Wifi support) firmware link

8 Responses to “Blinking a led on the Raspberry Pi Pico W”

  1. Roger Says:

    Thank You. was surprised when a simple book example failed to light the Led and thought it must be due to changes on my W model. Luckily your post came up on a search and solved the issue. I used your first two lines rather than the pin 25 code I had, then used blink

    from machine import Pin
    import utime
    led_onboard = Pin(“LED”, Pin.OUT)
    while True:

  2. Joe Says:

    Thanks a lot, I encountered the same problem while reading the official guide “Get Started with MicroPython on Raspberry Pi Pico”.

    Another way to make the LED blink:

    import utime
    from machine import Pin

    led_onboard = Pin(“LED”, Pin.OUT)

    while True:

  3. Guy Says:

    hey guys.

    not working for me.
    got my pico w today .. cannot get it to blink

    “LED” – error that it should be integer
    25, nothing happens

    any idea ?


  4. webonomic Says:

    @Guy, have you double checked you downloaded the right firmware. You need the Pico W version not the Pico.

  5. Guy Says:


    It appears that i indeed loaded the wrong uf2 file.

    Thank you @webonomic

    Now it is working better.

    Though i see many stuff not like the pi pico without wifi.

    Thank you


  6. omgitskuei Says:

    This example is via interpreter MicroPython. What if we’re using C/C++ SDK?

  7. fraz Says:

    @omgitskuei I was struggling with the C/C++ side of this as well, but finally found a tutorial explaining it. Turns out the pico-examples come with a pico_w/ directory with a separate blink example. See here for more info:

  8. hundred1906 Says:

    I found that for the Blink examples it is necessary to use the keyword ‘LED’. That is with single quotes, not double.

Leave a Reply