from machine import Pin
from utime import sleep
# configuration des boutons
pin_bouton_rouge = Pin(32, Pin.IN, Pin.PULL_UP)
pin_bouton_vert = Pin(33, Pin.IN, Pin.PULL_UP)
pin_bouton_jaune = Pin(25, Pin.IN, Pin.PULL_UP)
pin_bouton_blue = Pin(26, Pin.IN, Pin.PULL_UP)
# configuration des LEDs
pin_led_rouge = Pin(27, Pin.OUT)
pin_led_vert = Pin(14, Pin.OUT)
pin_led_jaune = Pin(12, Pin.OUT)
pin_led_blue = Pin(13, Pin.OUT)
while True:
# LED rouge
if pin_bouton_rouge.value():
pin_led_rouge.on()
else:
pin_led_rouge.off()
# LED vert
if pin_bouton_vert.value():
pin_led_vert.on()
else:
pin_led_vert.off()
# LED jaune
if pin_bouton_jaune.value():
pin_led_jaune.on()
else:
pin_led_jaune.off()
# LED blue
if pin_bouton_blue.value():
pin_led_blue.on()
else:
pin_led_blue.off()
sleep(0.1)