# Traffic lights: a free micro:bit lesson from Maze Education
# https://maze.education/microbit/lessons/traffic-lights
# MicroPython for the micro:bit Python Editor: https://python.microbit.org

# Traffic lights: red at the top, amber in the middle, green at the bottom. A asks to cross.
from microbit import *


def show_light(row):
    display.clear()
    for x in range(5):
        display.set_pixel(x, row, 9)


while True:
    show_light(4)
    sleep(3000)
    show_light(2)
    sleep(1000)
    show_light(0)
    if button_a.was_pressed():
        sleep(1000)
        display.show(Image.STICKFIGURE)
        sleep(3000)
    else:
        sleep(3000)
