from machine import Pin
import time
# Definir pines de filas (GPIO 0-6)
filas = [Pin(i, Pin.OUT) for i in range(7)]
# Definir manualmente los pines de columnas (Evita RUN)
columnas_pines = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 26, 27, 28] # 19 pines válidos
columnas = [Pin(i, Pin.OUT) for i in columnas_pines]
# Matriz de la palabra "HOLA" en una matriz 7x19
mensaje = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
]
fila_descarga = [1] * 19
def mostrar_matriz(matriz, tiempo=0.005):
for i in range(7):
for j in range(19):
columnas[j].value(0)
filas[i].value(1)
for j in range(19):
columnas[j].value(matriz[i][j])
time.sleep(tiempo)
filas[i].value(0)
for j in range(19):
columnas[j].value(fila_descarga[j])
time.sleep(0.0005)
for j in range(19):
columnas[j].value(0)
def desplazar_mensaje():
global mensaje
while True:
mostrar_matriz(mensaje)
for i in range(7):
mensaje[i] = mensaje[i][1:] + [mensaje[i][0]] # Mueve todo a la izquierda
time.sleep(0.02)
try:
desplazar_mensaje()
except KeyboardInterrupt:
for f in filas:
f.value(0)
for c in columnas:
c.value(0)