'''
from machine import Pin
from time import sleep
led1=Pin(1, Pin.OUT)
led2=Pin(12, Pin.OUT)
button1=Pin(26, Pin.IN)
button2=Pin(21, Pin.IN)
'--'
while True:
if(button1.value()==1):
led1.on()
sleep(1)
led1.off()
sleep(1)
if(button2.value()==1):
led2.on()
sleep(1)
led2.off()
sleep(1)
'--'
press_count=0
button_state=0
last_button_state=0
def toggle():
global press_count
if(press_count==1):
led1.on()
sleep(1)
led1.off()
elif(press_count==2):
led2.on()
sleep(1)
led2.off()
elif(press_count==3):
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()
sleep(0.2)
button_state=last_button_state
'''
from machine import Pin
from time import sleep
led1=Pin(1, Pin.OUT)
led2=Pin(12, Pin.OUT)
button1=Pin(26, Pin.IN)
button2=Pin(21, Pin.IN)
count=0
while True:
if button1.value()==1:
count += 1
if count % 4 != 0:
led1.on()
sleep(1)
led1.off()
else:
led1.on()
led2.on()
sleep(1)
led1.off()
led2.off()
if button2.value()==1:
count += 1
if count % 4 != 0:
led2.on()
sleep(1)
led2.off()
else:
led1.on()
led2.on()
sleep(1)
led1.off()
led2.off()