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
led.off() // turn it off again.
Do remember you need to download a different firmware for the Pico and the Pico W.
RPI Pico firmware link
https://micropython.org/download/rp2-pico/
September 14th, 2022 at 8:45 am
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:
led_onboard.toggle()
utime.sleep(5)
September 22nd, 2022 at 2:08 pm
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:
led_onboard.on()
utime.sleep(5)
led_onboard.off()
utime.sleep(5)
November 10th, 2022 at 4:11 pm
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 ?
thanks
November 11th, 2022 at 12:37 pm
@Guy, have you double checked you downloaded the right firmware. You need the Pico W version not the Pico.
https://micropython.org/download/rp2-pico-w/
November 14th, 2022 at 5:12 pm
Hello
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
Guy
January 18th, 2023 at 10:12 am
This example is via interpreter MicroPython. What if we’re using C/C++ SDK?
January 22nd, 2023 at 6:47 am
@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: https://www.electromaker.io/blog/article/getting-started-with-the-raspberry-pi-pico-w-cc-sdk
March 2nd, 2023 at 3:24 pm
I found that for the Blink examples it is necessary to use the keyword ‘LED’. That is with single quotes, not double.