from machine import Pin, Timer
from time import sleep
led = Pin(22,Pin.OUT)
button_pin19 = Pin(34, Pin.IN, Pin.PULL_DOWN)
def handler_2(tim2):
led.value(not led.value())
tim2=Timer(2)
switch=0
while True:
if button_pin19.value()==1:
sleep(0.1)
if button_pin19.value()==1:
switch = switch+1
if switch ==1:
tim2.init(period=200, mode=Timer.PERIODIC, callback=handler_2)
elif switch == 2:
tim2.init(period=500, mode=Timer.PERIODIC, callback=handler_2)
switch_status = "The value of switch is {}"
print(switch_status .format(switch),end = "\r")
tim2.deinit()
switch=0
sleep(0.1)
led.value(0)