#CBTIS122
#ELECTRONICA
#PROGRAMA CIRCUITOS CON MICROCONTROLADORRS
#MAESTRO: LESLIE YAMILETH RAMIREZ NUÑEZ
#ALUMNA: LESLIE YAMILETH RAMIREZ NUÑEZ
#FECHA DE INICIO: 28 DE OCTUBRE 2025
#FECHA DE ENTREGA: 04 DE NOVIEMBRE 2025
#NUMERO DE LISTA: 24
#GRADO Y GRUPO: 5M
#PRACTICA 302
#DISPLAY CUADRUPLE 7 SEGMENTOS
from machine import Pin
from time import sleep
# Segmentos A–G + DP en pines 2 al 9
seg = [Pin(i, Pin.OUT) for i in range(2, 10)]
# Dígitos D1–D4 en pines 10 al 13
dig = [Pin(i, Pin.OUT) for i in range(10, 14)]
# Tabla para CÁTODO COMÚN (1 = encendido, 0 = apagado)
num = [
[1,1,1,1,1,1,0,0], # 0
[0,1,1,0,0,0,0,0], # 1
[1,1,0,1,1,0,1,0], # 2
[1,1,1,1,0,0,1,0], # 3
[0,1,1,0,0,1,1,0], # 4
[1,0,1,1,0,1,1,0], # 5
[1,0,1,1,1,1,1,0], # 6
[1,1,1,0,0,0,0,0], # 7
[1,1,1,1,1,1,1,0], # 8
[1,1,1,1,0,1,1,0] # 9
]
def mostrar_digito(d, n):
# Apaga todos los dígitos
for j in range(4):
dig[j].value(1)
# Activa el dígito actual
dig[d].value(0)
# Enciende los segmentos necesarios
for i in range(8):
seg[i].value(num[n][i])
sleep(0.002)
# Apaga el dígito antes del siguiente
dig[d].value(1)
def mostrar_numero(valor):
s = "{:04d}".format(valor) # convierte 5 → "0005"
for j in range(4):
mostrar_digito(j, int(s[j]))
contador = 0
while True:
# refresco visual del número
for _ in range(30):
mostrar_numero(contador)
# incrementa el contador
contador += 1
if contador > 9999:
contador = 0