from machine import Pin # hardware library for pin
import time # time library
led1=Pin(9,Pin.OUT) #declare led at pin GP9
led2=Pin(10,Pin.OUT) #declare led at pin GP10
sw=Pin(21, Pin.IN, Pin.PULL_UP) #declare switch at GP21 as input PULLUP
led1.on() #on led1
led2.on() #on led2
print("starting...") #print message
time.sleep(1) #delay 1 sec
while(1): #always loop
if(sw.value()==0): #if switch is pressed
led1.toggle() #led1 tonggle
print("led 1 is blinking") #print message
else: #if switch is depressed
led2.toggle() #led2 toggle
print("led 2 is blinking") #print message
time.sleep(0.5) #delay 0.5 second