from machine import Pin
from utime import sleep
print("Hello, Pi Pico!")
# Green LED connected on Pin 6
led2 = Pin(5, Pin.OUT)
# Red LED connected on Pin 7
led1 = Pin(6,Pin.OUT)
# Pushbutton connected on Pin 28
pushButton = Pin(28, machine.Pin.IN, machine.Pin.PULL_UP)
while True:
if pushButton.value(): # Check if the button is NOT pressed (HIGH)
led1.on() # Turn the red LED ON
led2.off() # Turn the green LED OFF
sleep(0.01)
else:
led1.off() # Turn red LED off
led2.on() # Turn green LED ON
sleep(0.01)
print ('button pressed') # used for troubleshooting