from machine import Pin, ADC
import time
a = Pin(0, Pin.OUT)
b = Pin(1, Pin.OUT)
c = Pin(2, Pin.OUT)
d = Pin(3, Pin.OUT)
e = Pin(4, Pin.OUT)
f = Pin(5, Pin.OUT)
g = Pin(6, Pin.OUT)
segments = [a, b, c, d, e, f, g]
bouton = Pin(15, Pin.IN, Pin.PULL_DOWN)
pot = ADC(26)
nombres = {
0: [a, b, c, d, e, f],
1: [b, c],
2: [a, b, d, e, g],
3: [a, b, c, d, g],
4: [b, c, f, g],
5: [a, c, d, f, g],
6: [a, c, d, e, f, g],
7: [a, b, c],
8: [a, b, c, d, e, f, g],
9: [a, b, c, d, f, g],
}
liste = [1,2,3,4,5,6]
def eteindre_segments():
for segment in segments:
segment.value(1)
def lire_nombre(n):
for segment in nombres[n]:
segment.value(0)
while True:
if bouton.value()==0 :
val = pot.read_u16()
nombre = int(val / 65535 * 10)
if nombre in liste:
lire_nombre(nombre)
else:
eteindre_segments()
time.sleep(0.1)