from machine import Pin
from time import sleep
led1=Pin(5, Pin.OUT)
led2=Pin(15, Pin.OUT)
button1=Pin(22, Pin.IN)
'''
while True:
if(button1.value()==1):
led1.on()
sleep(0.5)
led1.off()
sleep(0.5)
if(button2.value()==1):
led1.on()
led1.off()
led2.on()
led2.off()
'''
press_count=0
last_button_state=0
button_state=0
def toggle():
global press_count
if(press_count==1):
led1.on()
sleep(1)
led1.off()
led2.on()
sleep(1)
led2.off()
elif(press_count==2):
led1.on()
led2.on()
else:
led1.off()
led2.off()
press_count=0
while True:
button_state=button1.value()
if button_state==1 and last_button_state==0:
press_count+=1
toggle()
last_button_state=button_state