Skip to content

Instantly share code, notes, and snippets.

@Sh0cko
Last active May 14, 2025 21:21
Show Gist options
  • Save Sh0cko/491d2df0e610b113f0248057053a8c5b to your computer and use it in GitHub Desktop.
Save Sh0cko/491d2df0e610b113f0248057053a8c5b to your computer and use it in GitHub Desktop.

Practica 0, 1 y 2 en Rapberry pi pico w

Joel Cuevas Estrada - 22210298

Practica 0

Instalación de Firmware de Micropython Se descarga el firmware desde micropython.org image

El archivo descargado se arrastra desde el directorio de descargar a la Pi Pico W

Practica 1

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

Practica 2

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment