1st… need to add the library imports begining of code…:
import machine
from machine import Pin
2nd…code I added to be able to read the pin…was using D9 as an input
note: button is hte pin object
code:
button = Pin.board.D9 # initialize the variable
button.mode(Pin.IN) # set pin D9 for input
button.pull(Pin.PULL_UP) # set to pulled up HIGH
buttonState = button.value() # read pin should be high or 1
I had a bit of a time deciphering all the different documentation to do this, even though it turns out to be pretty easy!