# Update this code so that the green light remains on until button is pressed. Once the button is pressed the red light should flash the SOS signal
from machine import Pin
from utime import sleep
print("Hello, Pi Pico!")
# Green LED connected on Pin 2
led2 = Pin(2, Pin.OUT)
# Red LED connected on Pin 10
led1 = Pin(10,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.5)
else:
led1.off() # Turn red LED off
led2.on() # Turn green LED ON
sleep(0.5)
print ('button pressed') # used for troubleshooting