Change in Pico LED pin definition
With the launch of the Pi Pico W, we now have the ability to easily connect a simple device to the Internet! To achieve this, however, a few changes had to be done to the way the LED was controlled on the Pico W. It is no longer on GPIO pin 25 as noted below:
Unlike the original Raspberry Pi Pico, the on-board LED on Pico W is not connected to a pin on RP2040, but instead to a GPIO pin on the wireless chip. MicroPython has been modified accordingly. This means that you can now do:
>>> import machine >>> led = machine.Pin("LED", machine.Pin.OUT) >>> led.off() >>> led.on()
- Source: Connecting to the Internet with Raspberry Pi Pico W, Section 3.4, retrieved 2022-08-03
This means that Python examples that haven't been updated to the new "LED" pin definition will fail to light the LED on Pico W.
The fix is easy, though! Just replace ' 25' with "LED" like in the example below:
led_onboard = machine.Pin(25, machine.Pin.OUT)
led_onboard = machine.Pin("LED", machine.Pin.OUT)
This will work on ALL Pi Picos that have a recent MicroPython.
You can find the latest versions on the official documentation page: Raspberry Pi Microcontrollers - MicroPython
Note that the Pico and Pico W use different files!
Note that in some cases, examples for Pico W are in a separate folder. This is the case for the Blink C/C++ examples in pico-examples, the Pico W example is in the pico-examples/pico_w/blink subfolder. Using the example in pico-examples/blink won't work with the Pico W!
For more information, please refer to the official C/C++ SDK documentation.