# from machine import Pin
# from time import*
# ledO = Pin(2, Pin.OUT)
# ledR = Pin(3, Pin.OUT)
# bouton = Pin(4, Pin.PULL_DOWN)
# btn = Pin(5, Pin.PULL_DOWN)
# # bouton_mem = False
# while True:
# sleep(0.1)
# if bouton.value()==1:
# sleep(0.1)
# if btn.value()==0:
# ledR.on()
# sleep(1)
# ledR.off()
# ledO.on()
# sleep(1)
# ledO.off()
# else:
# ledR.off()
# ledO.off()
# from machine import Pin
# from time import sleep,sleep_ms
# ledO = Pin(2, Pin.OUT)
# ledR = Pin(3, Pin.OUT)
# bouton1 = Pin(4, Pin.PULL_DOWN)
# btn2 = Pin(5, Pin.PULL_DOWN)
# while True :
# sleep_ms(10)
# if bouton1.value() == 1:
# while btn2.value() == 0:
# ledO.on()
# sleep(1)
# ledO.off()
# ledR.on()
# sleep(1)
# ledR.off()
# # if bouton1.value()==1 and btn2.value()==1:
# from machine import Pin
# from time import sleep,sleep_ms
# ledO = Pin(2, Pin.OUT)
# ledR = Pin(3, Pin.OUT)
# bouton1 = Pin(4, Pin.PULL_DOWN)
# btn2 = Pin(5, Pin.PULL_DOWN)
# temps = 0
# while True :
# sleep_ms(1)
# if bouton1.value() == 1:
# while btn2.value() == 0:
# temps+=1
# sleep_ms(10)
# if temps <= 100:
# ledO.on()
# ledR.off()
# if temps >= 100:
# ledR.on()
# ledO.off()
# if temps >200:
# ledR.off()
# temps=0
# from machine import Pin
# from time import sleep,sleep_ms, ticks_diff,ticks_ms
# ledO = Pin(2, Pin.OUT)
# ledR = Pin(3, Pin.OUT)
# bouton1 = Pin(4, Pin.PULL_DOWN)
# btn2 = Pin(5, Pin.PULL_DOWN)
# temps = 0
# while True :
# if bouton1.value() == 1:
# temps = ticks_ms()
# while btn2.value() == 0:
# if ticks_diff(ticks_ms(), temps) >= 1000:
# ledO.off()
# ledR.on()
# else:
# ledO.on()
# ledR.off()
# if ticks_diff(ticks_ms(), temps) >= 2000:
# temps = ticks_ms()
# from machine import Pin
# from time import sleep,sleep_ms, ticks_diff,ticks_ms
# ledO = Pin(2, Pin.OUT)
# ledR = Pin(3, Pin.OUT)
# bouton1 = Pin(4, Pin.PULL_DOWN)
# btn2 = Pin(5, Pin.PULL_DOWN)
# bouton1_mem = False
# temps = 0
# while True :
# if bouton1.value() != bouton1_mem:
# sleep_ms(50)
# bouton1_mem = bouton1.value()
# temps = ticks_ms()
# if bouton1.value():
# ledR.on()
# sleep(1)
# ledR.off()
# ledO.on()
# sleep(1)
# ledO.off()
from machine import Pin
from time import sleep,sleep_ms, ticks_diff,ticks_ms
ledO = Pin(2, Pin.OUT)
ledR = Pin(3, Pin.OUT)
bouton1 = Pin(4, Pin.PULL_DOWN)
btn2 = Pin(5, Pin.PULL_DOWN)
bouton1_mem = False
btn2_mem = False
temps = 0
etat = 1
entry = True
exit = False
while True:
sleep_ms(10)
if etat == 1:
if entry:
ledO.off()
entry = False
bouton1_mem = bouton1.value()
else:
if bouton1.value() != bouton1_mem:
bouton1_mem = bouton1.value()
ledO.on()
if bouton1.value():
# if btn2.value() == 1:
# ledR.on()
etat = 2
exit = True
if exit:
# if btn2.value() == 1:
# ledR.on()
exit = False
if etat == 2 :
if entry:
# if btn2.value() == 1:
# ledR.on()
entry = True
bouton1_mem = bouton1.value()
else:
if bouton1.value() != bouton1_mem:
bouton1_mem = bouton1.value()
ledO.off()
ledR.off()
if btn2.value() != btn2_mem:
btn2_mem = btn2.value()
if btn2.value() == 1:
ledR.on()
if bouton1.value():
etat = 1
exit = False
if exit:
exit = True