sábado, 9 de noviembre de 2024

For Pico W, the pin number for on board Led is "WL_GPIO0". Len onboard in pico W is WL-GPIO0

For Pico W, the pin number for on board Led is "WL_GPIO0".

https://raspberrypi.stackexchange.com/questions/140413/led-light-not-turning-on


Appendix B - Blinking onboard LED

(1) For Pico W, the pin number for on board Led is "WL_GPIO0".

Yes, no longer number 25 for Pico.

(2) The following program blinks onboard LED. The correct statement to initialize the Led should be:

LED = Pin("WL_GPIO0", Pin.OUT)

Update: The following also looks OK:

LED = Pin("LED", Pin.OUT)

There is some confusion here: the first LED is an object, the second is the pin number for the onboard pin (same of WL+GPIO0) (Appendix H)

(3) Full listing of the folly debugged program:


# Name      - Rpi Pico W onboard LED v4.3  tlfong01  2022dec29hkt1502
# Function  - Blink onboard LED
# References -
#   (1) Blink onboard LED  https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/5
#   (2) Onboard LED pinout https://core-electronics.com.au/guides/raspberry-pi-pico/raspberry-pi-pico-w-overview-features-specs/

import machine
from machine import Pin, Timer
timer = Timer()

LED = Pin("WL_GPIO0", Pin.OUT)

def blink(timer):
    LED.toggle()
    
timer.init(freq = 1, mode = Timer.PERIODIC, callback = blink)




# Name      - Rpi Pico W onboard LED v4.3  tlfong01  2022dec29hkt1502
# Function  - Blink onboard LED
# References -
#   (1) Blink onboard LED  https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/5
#   (2) Onboard LED pinout https://core-electronics.com.au/guides/raspberry-pi-pico/raspberry-pi-pico-w-overview-features-specs/

import machine
from machine import Pin, Timer
timer = Timer()

#LED = Pin("WL_GPIO0", Pin.OUT)
LED = Pin("LED", Pin.OUT)

def blink(timer):
    LED.toggle()
    
timer.init(freq = 2, mode = Timer.PERIODIC, callback = blink)




Appendix G - PicoW Concurrently Blink 2 LEDs Complete Program Listing

# Pico W Concurrently Blink Two LEDs - tlfong01 2022dec30hkt1350

# *** Modules ***
import machine
from machine import Pin, Timer

# *** Objects ***
redTimer    = Timer()
redLed      = Pin(15, Pin.OUT)

greenTimer  = Timer()
greenLed    = Pin(0, Pin.OUT)

# *** Callback Functions ***
def blinkRedLed(dummy):
    redLed.toggle()
    return

def blinkGreenLed(dummy):
    greenLed.toggle()
    return

# *** Main Functions***
redTimer.init(freq = 2, mode = Timer.PERIODIC, callback = blinkRedLed)
greenTimer.init(freq = 4, mode = Timer.PERIODIC, callback = blinkGreenLed)

# *** End of program ***

No hay comentarios:

Publicar un comentario