from machine import Pin
from utime import sleep
# Initialize pins for the two 7-segment displays
seg7_display1 = [Pin(0, Pin.OUT), Pin(1, Pin.OUT), Pin(2, Pin.OUT),
Pin(3, Pin.OUT), Pin(4, Pin.OUT), Pin(5, Pin.OUT),
Pin(6, Pin.OUT), Pin(7, Pin.OUT)] # Display 1: abcdefgh
seg7_display2 = [Pin(8, Pin.OUT), Pin(9, Pin.OUT), Pin(10, Pin.OUT),
Pin(11, Pin.OUT), Pin(12, Pin.OUT), Pin(13, Pin.OUT),
Pin(14, Pin.OUT), Pin(15, Pin.OUT)] # Display 2: abcdefgh
# Segment patterns for digits 0-9
seg7_table = [[1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 0, 1, 1, 0, 1, 0], [1, 1, 1, 1, 0, 0, 1, 0],
[0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 1, 1, 0, 1, 1, 0],
[1, 0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 0, 1, 1, 0]]
# Function to display a digit on a 7-segment display
def display7(display, value):
val = int(value) # Convert to integer
for j in range(8):
display[j].value(not(seg7_table[val][j]))
# Fixed number to display
number_to_display = 99
# Extract tens and ones place
tens = number_to_display // 10
ones = number_to_display % 10
# Display the number on the two 7-segment displays
display7(seg7_display1, tens) # Display tens place
display7(seg7_display2, ones) # Display ones place
# Optionally, keep the display on for a while
sleep(5)