Instalación de Firmware de Micropython
Se descarga el firmware desde micropython.org
El archivo descargado se arrastra desde el directorio de descargar a la Pi Pico W
Despliegue de "Hola Mundo" con parpadeo de LED integrado
from machine import Pin
from time import sleep
# LED integrado de la Raspberry Pi Pico W (GPIO 15)
led = Pin("LED", Pin.OUT)
# Mensaje por consola serial
print("Hola mundo desde la Raspberry Pi Pico W")
# Bucle para parpadear el LED
while True:
led.toggle()
sleep(0.5) # espera 500 milisegundos
Desplegar la hora usando internet (Serial Print) -8 PST
import network
import ntptime
import time
from machine import Pin
# Configura tu red Wi-Fi
SSID = 'TU_SSID'
PASSWORD = 'TU_PASSWORD'
def conectar_wifi():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('Conectando a la red...')
wlan.connect(SSID, PASSWORD)
while not wlan.isconnected():
time.sleep(1)
print('Conectado. IP:', wlan.ifconfig()[0])
# Ajustar la hora local (UTC-8 para PST)
def hora_local():
t = time.localtime(time.time() - 8 * 3600) # UTC -8 horas
return "{:02d}/{:02d}/{} {:02d}:{:02d}:{:02d}".format(t[2], t[1], t[0], t[3], t[4], t[5])
# Main
conectar_wifi()
print("Sincronizando con NTP...")
ntptime.settime()
while True:
print("Hora actual (PST):", hora_local())
time.sleep(5)