from machine import Pin
import time
time.sleep(0.1)#wait for USB to become ready
ext_led= Pin(15,Pin.OUT)
button=Pin(14,Pin.IN,Pin.PULL_DOWN)
print()
last_state=0
while True:
current_state=button.value()
if current_state==1 and last_state==0:
print("Button PRESSED")
elif current_state==0 and last_state==1:
print("Button RELEASED")
ext_led.value(current_state)
last_state=current_state
time.sleep(0.05)