from machine import Pin
import utime as time
import uasyncio as asyncio
# Defining LED and button pins
Led_green = Pin(19, Pin.OUT) # Green LED
Led_yellow = Pin(22, Pin.OUT) # Yellow LED
Led_red = Pin(21, Pin.OUT) # Red LED
button_left = Pin(23, Pin.IN, Pin.PULL_UP) # Pedestrian Button, Bp
button_right = Pin(18, Pin.IN, Pin.PULL_UP) # Intermitent Button, Bi
# Initialize state variables
blink_mode = False
async def normal_cycle():
Led_red.on()
await asyncio.sleep(4)
Led_red.off()
Led_green.on()
await asyncio.sleep(9)
Led_green.off()
Led_yellow.on()
await asyncio.sleep(1)
Led_yellow.off()
Led_red.on()
# Function for the blink mode
async def blink(pin, event):
global blink_mode
blink_mode = not blink_mode
while blink_mode:
Led_yellow.value(not Led_yellow.value())
await asyncio.sleep(1)
async def button_right_state():
global blink_mode
while True:
async def main():
normal_cycle(),
button_right_state()
# Run the event loop
asyncio.run(main())