Código de Control LED y Display
1:20
led_patterns. El código corregido es:Python
import board import digitalio import time # Defino 6 pines leds = [board.GP0, board.GP1, board.GP2, board.GP3, board.GP4, board.GP5] # Configura los LEDs como salidas digitales led_pins = [digitalio.DigitalInOut(pin) for pin in leds] for led_pin in led_pins: led_pin.direction = digitalio.Direction.OUTPUT # Define los patrones de LEDs para las secuencias 0 a 9 led_patterns = [ [1, 0, 0, 0, 0, 1], # Sec 0 [0, 0, 0, 0, 0, 1], # Sec 1 [1, 0, 0, 0, 0, 1], # Sec 2 [0, 0, 0, 0, 0, 1], # Sec 3 [0, 1, 0, 0, 0, 1], # Sec 4 [0, 0, 1, 1, 0, 0], # Sec 5 [0, 0, 1, 0, 0, 0], # Sec 6 [0, 0, 1, 1, 0, 0], # Sec 7 [0, 0, 1, 0, 0, 0], # Sec 8 [0, 0, 1, 0, 1, 0] # Sec 9 ] # Función para desplegar un patrón de LEDs def display_pattern(sequence): for i in range(6): led_pins[i].value = led_patterns[sequence][i] time.sleep(2.0) # Programa principal while True: for sequence in range(10): display_pattern(sequence)
segments en lugar de la lista definida leds.segments_pins en vez de segment_pins.digit); se ha corregido a digit obtenido del bucle.Python
import board import digitalio import time # Defino 7 pines para los segmentos leds = [board.GP8, board.GP9, board.GP10, board.GP11, board.GP12, board.GP13, board.GP14] # Definir pin para cátodo común common_catode = board.GP15 # Configura los pines de los segmentos como salidas digitales segment_pins = [digitalio.DigitalInOut(pin) for pin in leds] for segment_pin in segment_pins: segment_pin.direction = digitalio.Direction.OUTPUT # Configura el pin del cátodo común como salida digital common_catode_pin = digitalio.DigitalInOut(common_catode) common_catode_pin.direction = digitalio.Direction.OUTPUT # Define los patrones de dígitos para un display de 7 segmentos (cátodo común) digit_patterns = [ [1, 1, 1, 1, 1, 1, 0], # Dígito 0 [0, 1, 1, 0, 0, 0, 0], # Dígito 1 [1, 1, 0, 1, 1, 0, 1], # Dígito 2 [1, 1, 1, 1, 0, 0, 1], # Dígito 3 [0, 1, 1, 0, 0, 1, 1], # Dígito 4 [1, 0, 1, 1, 0, 1, 1], # Dígito 5 [1, 0, 1, 1, 1, 1, 1], # Dígito 6 [1, 1, 1, 0, 0, 0, 0], # Dígito 7 [1, 1, 1, 1, 1, 1, 1], # Dígito 8 [1, 1, 1, 1, 0, 1, 1] # Dígito 9 ] def display_digit(digit): for i in range(7): segment_pins[i].value = digit_patterns[digit][i] common_catode_pin.value = False # Activa el cátodo común en un display de cátodo común time.sleep(0.5) # Programa principal while True: for digit in range(10): display_digit(digit)
Reviews
Confident Tomato Robot Maid
Properties
Properties describe core aspects of the project.
Pricing & Availability
Distributor | Qty 1 |
|---|
Controls
Welcome 👋
Flux helps you build PCBs faster with an AI teammate!
Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.

AI-Powered Component Placement
Let AI place your components intelligently. AI Placement analyzes your schematic and positions components for optimal routing, signal integrity, and board density.
From Schematic to Layout in Seconds
Skip the tedious manual placement. AI Placement generates a starting layout you can refine, saving hours of repetitive work on every new design.
Works With Auto-Layout
Pair AI Placement with Auto-Layout for a complete AI-driven PCB design flow — from component placement through trace routing, all with one click.