I'm trying to code a button to turn and LED on and off.
from machine import Pin
led = Pin(16, Pin.OUT)
button = Pin(17, Pin.IN)
while True:
if button.value()==1:
led.high()
print("hello")
if button.value()==0:
led.low()
This is all running on a Pi Pico W. I notice the LED turns on anytime a wire is connected to pin 17, even if the wire isn't plugged into anything else. When I push the button it lights up brighter, and prints Hello.
Any help would be greatly appreciated, thanks!