llamanuma
Posts: 2
Joined: Fri Jul 01, 2022 2:40 pm

Pico W onboard LED not working [SOLVED]

Fri Jul 01, 2022 3:15 pm

Hi folks :D I'm a long time Raspberry Pi user and am excited to have received my first Pico today – the Pico W!

Following the Getting Started guide I'm struggling to get the onboard LED to light up and am not sure if I have a defective unit or am doing something daft (equally likely!) So far I've flashed the Pico W specific MicroPython firmware, and am able to connect to the REPL on the device via serial over USB. Next I followed the instructions and ran

Code: Select all

from machine import Pin
led = Pin(25, Pin.OUT)
led.value(1)
but the LED remains unlit. I can verify that the pin has been set with

Code: Select all

led.value()  # returns 1
Any ideas what I might be doing wrong? Thanks in advance!

trejan
Posts: 6161
Joined: Tue Jul 02, 2019 2:28 pm

Re: Pico W onboard LED not working

Fri Jul 01, 2022 3:30 pm

The LED is no longer directly attached to the RP2040.
https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf wrote:3.4. The on-board LED

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:

Code: Select all

import machine
led = machine.Pin("LED", machine.Pin.OUT)
led.off()
led.on()

llamanuma
Posts: 2
Joined: Fri Jul 01, 2022 2:40 pm

Re: Pico W onboard LED not working

Fri Jul 01, 2022 3:58 pm

Ah perfect, that was it. Thanks trejan.

clintonlucas
Posts: 17
Joined: Sun Apr 27, 2014 11:15 am

Re: Pico W onboard LED not working [SOLVED]

Thu Jul 07, 2022 6:38 pm

Hello

I wonder if anyone could help, I copied and pasted the code given in the solution to the LED problem:

import machine
led = machine.Pin("LED", machine.Pin.OUT)
led.off()
led.on()

However it gave me the following error:

Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: can't convert str to int

Thanks

cleverca22
Posts: 7761
Joined: Sat Aug 18, 2012 2:33 pm

Re: Pico W onboard LED not working [SOLVED]

Thu Jul 07, 2022 6:39 pm

clintonlucas wrote:
Thu Jul 07, 2022 6:38 pm
I wonder if anyone could help, I copied and pasted the code given in the solution to the LED problem:
did you use the pico-w build of micropython?

clintonlucas
Posts: 17
Joined: Sun Apr 27, 2014 11:15 am

Re: Pico W onboard LED not working [SOLVED]

Thu Jul 07, 2022 7:03 pm

I have used the Pico one that comes up on the list of interpreters on Thonny.

trejan
Posts: 6161
Joined: Tue Jul 02, 2019 2:28 pm

Re: Pico W onboard LED not working [SOLVED]

Thu Jul 07, 2022 7:07 pm

clintonlucas wrote:
Thu Jul 07, 2022 7:03 pm
I have used the Pico one that comes up on the list of interpreters on Thonny.
That is the wrong one. Follow the instructions on https://micropython.org/download/rp2-pico-w/

The Thonny list needs to be updated as Pico and Pico W need different builds of MicroPython. Thonny only having the Pico build explains why there have been several people with it on their Pico W.

hippy
Posts: 14344
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Pico W onboard LED not working [SOLVED]

Fri Jul 08, 2022 10:21 am

Just to note that I've added a post for controlling the on-board LED in the Sticky for MicroPython resources.

clintonlucas
Posts: 17
Joined: Sun Apr 27, 2014 11:15 am

Re: Pico W onboard LED not working [SOLVED]

Fri Jul 08, 2022 4:12 pm

Thanks the updated interpreter has worked fine.

clintonlucas
Posts: 17
Joined: Sun Apr 27, 2014 11:15 am

Re: Pico W onboard LED not working [SOLVED]

Fri Jul 08, 2022 4:13 pm

trejan wrote:
Thu Jul 07, 2022 7:07 pm
clintonlucas wrote:
Thu Jul 07, 2022 7:03 pm
I have used the Pico one that comes up on the list of interpreters on Thonny.
That is the wrong one. Follow the instructions on https://micropython.org/download/rp2-pico-w/

The Thonny list needs to be updated as Pico and Pico W need different builds of MicroPython. Thonny only having the Pico build explains why there have been several people with it on their Pico W.
Thanks all working fine now.

Schorschi
Posts: 362
Joined: Thu Nov 22, 2012 9:38 pm

Re: Pico W onboard LED not working [SOLVED]

Mon Jul 25, 2022 4:15 pm

Is there, yet, a way to determine the model of Pico in micropython? Would like to add to my scripting an exception if the script is running on the wrong device type? For example, a could with ease, set LED to 25 for original Pico, and 'LED' for Pico W if I could determine the Pico device model or type?

hippy
Posts: 14344
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Pico W onboard LED not working [SOLVED]

Mon Jul 25, 2022 4:55 pm

Schorschi wrote:
Mon Jul 25, 2022 4:15 pm
Is there, yet, a way to determine the model of Pico in micropython? Would like to add to my scripting an exception if the script is running on the wrong device type?
AFAIK, not as yet. It's easy enough to add - viewtopic.php?p=2015757

It would be worth raising an issue on MicroPython to have that functionality included if not already raised - https://github.com/micropython/micropyt ... 3Aport-rp2
Schorschi wrote:
Mon Jul 25, 2022 4:15 pm
For example, a could with ease, set LED to 25 for original Pico, and 'LED' for Pico W if I could determine the Pico device model or type?
For that, using 'LED' for both is the better option.

Schorschi
Posts: 362
Joined: Thu Nov 22, 2012 9:38 pm

Re: Pico W onboard LED not working [SOLVED]

Mon Aug 08, 2022 5:27 am

I raised the issue with MicroPython team, they told me to go pound sand, nicely, but still refused to create a common MicroPython image that is universal across Pico and Pico W devices.

So I wrote a function to do it. Based on the official SDK for pico.

Code: Select all

#----------------------------------------
# Model...
#   https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
#----------------------------------------
def Model():
    
    from machine import Pin, ADC
    
    LEVEL=0.3
    ADC=3
    PIN=25
    
    # Ensure Pin 25 Low...
    thePin=Pin(PIN, mode=Pin.IN, pull=Pin.PULL_DOWN, value=ZERO)

    # Measure ADC Register 3...
    theVoltage=ReadADC(ADC)
 
    if (theVoltage > LEVEL): # 1/3 VSYS, Not Almost Zero? Test As 0.4 Or Greater
        
        #
        theModel='Pico'
        
    if (theVoltage < LEVEL): # Close To Zero? Test As 0.022 Or Slight Greater
        
        #
        theModel='Pico W'
    
    #
    Echo("Pico! Voltage {0} V, Model {1}'".format(theVoltage, theModel))
    
    #
    return theModel

Return to “MicroPython”