from machine import Pin  # hardware library for pin
import time               # time library

led1=Pin(0,Pin.OUT)  #declare led at pin GP0 (green)
led2=Pin(2,Pin.OUT)  #declare led at pin GP2 (red)
sw=Pin(15, Pin.IN, Pin.PULL_UP) #declare switch at GP15 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

BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT