Digimeshkit and Python and IO as digital input...what to import/library etc?

I want to set DIO9 as a digital input, and can do that thru XCTU…
Quesiton in software I am using Pycharm with DIGI plugin, and writing python code…

What import lib and how do I add this to the software or in the Python proj to intialize, and from examples I shoul be able to use something like:

value = xbee.get_dio_value(IOLine.DIO9)

When I add that, it flags that "IOLine is not defined or found!

How do I correct this…

Thanks,
Bert

ok…found the answer i needed myself…

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!

Hope this helps someone else!
Bert

1 Like