from machine import Pin # import Pin class
import time # import time module
# create pin object from Pin22, set Pin22 to input
pinIn = Pin(22, Pin.IN, Pin.PULL_UP)
pinLED = Pin(28, Pin.OUT) # create pin object from Pin25, set Pin25 to output
while True: # create an infinite loop
while pinIn.value() == 0: # if pinIn is released
pass # do nothing
t = time.ticks_ms() # get current time
time.sleep_ms(1) # sleep 1 millisecond
while pinIn.value() == 1: # if pinIn is pressed
pass # do nothing
t = time.ticks_diff(time.ticks_ms(), t) # get time difference
if t < 2000: # if time difference less than 2 seconds
pinLED.on() # set pinLED turn on
time.sleep(1) # sleep 1 second
pinLED.off() # set pinLED turn off
else: # if time difference more than 2 seconds
for i in range(10): # repeat 10 times
pinLED.on() # set pinLED turn on
time.sleep_ms(100) # sleep 100 milliseconds
pinLED.off() # set pinLED turn off
time.sleep_ms(100) # sleep 100 milliseconds