from time import sleep
from machine import Pin
sleep(0.1) # Wait for USB to become ready
button = Pin(1, Pin.IN, Pin.PULL_UP) #button_1r = pico_pin_1 | button_2r = pico_pin_gnd1
#Button defaults to on/1, and if pressed will be off/0.
led = Pin(0, Pin.OUT) #led_pin_A = pico_pin_0 | led_pin_C = pico_pin_gnd1
print("Led test starts now")
sleep(0.5)
for i in range(0,3): #runs the code 3 times. 0, 1 and 2 being the times run. for loops work as (n,n-1)
led.value(1) #same as led.on, sets the value of the pin high
print("led on")
sleep(0.5)
led.value(0) #same as led.off, sets the value of the pin low
print("led off")
sleep(0.5)
while True: #while true loop breaks after 1 times run.
led.value(1)
print("led on")
sleep(0.5)
led.value(0)
print("led off")
sleep(0.5)
break
print("Button test starts now")
sleep(0.5)
for i in range(0,30): #prints the button state, on or off / 1 or 0
print("Button state", button.value())
sleep(0.1)
print("Button + Led testes")
sleep(0.5)
while True:
if button.value() == 1:
print("button on, led on")
led.value(1)
elif button.value() == 0:
print("button off, led off")
led.value(0)
sleep(0.5)