from machine import Pin, ADC
from time import sleep
bvert = Pin(14,Pin.IN, Pin.PULL_UP)
brouge = Pin(18,Pin.IN, Pin.PULL_UP)
delvert = Pin(27,Pin.OUT)
delrouge = Pin(17,Pin.OUT)
etatrouge = False
potentionmetre = ADC(Pin(32))
temps_max= 3 # 3 secondes maximum pour clignoter
while True:
pourcent_potentio = int(100*potentionmetre.read()/4095)
delvert.value(0)
delrouge.value(etatrouge)
if bvert.value() == 0:
delvert.value(0)
sleep(pourcent_potentio*temps_max)
delvert.value(1)
sleep(pourcent_potentio*temps_max)
if brouge.value() == 0:
etatrouge = not etatrouge
sleep(0.5)