from machine import Pin
import time
number_of_display_pins = [
5, # hours
6 # seconds
]
pins = [
[ #hour
Pin(4, Pin.OUT),
Pin(3, Pin.OUT),
Pin(2, Pin.OUT),
Pin(1, Pin.OUT),
Pin(0, Pin.OUT),
],
[] #minutes
]
def number_to_binary(number, length):
binary_conversion = bin(number)[2:]
return "0" * (length - len(binary_conversion)) + binary_conversion
def show_binary_number(binary_number, display):
for bit_pos, bit in enumerate(binary_number):
if bit == "1":
pins[display][bit_pos].off()
else:
pins[display][bit_pos].on()
def show_number(number, display):
binary = number_to_binary(number, number_of_display_pins[display])
show_binary_number(binary, display)
def get_time():
pass
#return [hours, minutes]
def main():
while True:
current_time = get_time()
show_number(current_time[0], 0)
show_number(current_time[1], 0)
time.sleep(1)
show_number(7, 0)
Pin(5, Pin.OUT).on()