import machine
import time
RED_LED_PIN=1
YELLOW_LED_PIN=5
GREEN_LED_PIN=9
RED_BUTTON_PIN=14
YELLOW_BUTTON_PIN=17
GREEN_BUTTON_PIN=21
red_led=machine.Pin(RED_LED_PIN,machine.Pin.OUT)
yellow_led=machine.Pin(YELLOW_LED_PIN,machine.Pin.OUT)
green_led=machine.Pin(GREEN_LED_PIN,machine.Pin.OUT)
button_red=machine.Pin(RED_BUTTON_PIN,machine.Pin.IN,
machine.Pin.PULL_UP)
button_green=machine.Pin(GREEN_BUTTON_PIN,machine.Pin.IN,
machine.Pin.PULL_UP)
button_yellow=machine.Pin(YELLOW_BUTTON_PIN,machine.Pin.IN,
machine.Pin.PULL_UP)
def turn_on_led(led_Pin):
red_led.value=machine.Pin(led_pin==RED_BUTTON_PIN)
yellow_led.value=machine.Pin(led_pin==YELLOW_BUTTON_PIN)
green_led.value=machine.Pin(led_pin==GREEN_BUTTON_PIN)
def button_on_red_led(RED_LED_PIN):
while not button_red.value():
turn_on_led(RED_LED_PIN)
def button_on_red_led(RED_LED_PIN):
while not button_red.value():
turn_on_led(RED_LED_PIN)
def button_on_red_led(YELLOW_LED_PIN):
while not button_yellow.value():
turn_on_led(YELLOW_LED_PIN)
def button_on_red_led(GREEN_LED_PIN):
while not button_green.value():
turn_on_led(GREEN_LED_PIN)
while true
button_on_red_led(RED_LED_PIN)
button_on_red_led(RED_LED_PIN)
button_on_red_led(RED_LED_PIN)