import machine
import time
# print("Hello World!")
# Initialize the onboard LED using "LED"
led = machine.Pin("LED", machine.Pin.OUT)
exled = machine.Pin(0, machine.Pin.OUT)
# toggle = 0 #use push button to toggle led switch
# example from https://docs.wokwi.com/parts/wokwi-pushbutton
buttonIn = machine.Pin(2,machine.Pin.OUT)
buttonIn.value(1)
buttonOut = machine.Pin(3,machine.Pin.IN)
# help()
while True:
led.value(1) # Turn the LED on
print(buttonOut.value())
if buttonOut.value() == 1:
print("Button is pressed, External LED is on")
exled.value(1)
else:
print("Button is not pressed, External LED is off")
time.sleep(1) # Wait for 1 second
led.value(0) # Turn the LED off
exled.value(0)
time.sleep(1) # Wait for 1 second