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

**URL:** <https://forums.digi.com/t/digimeshkit-and-python-and-io-as-digital-input-what-to-import-library-etc/28381>\
**Category:** XBee - Zigbee\
**Created:** [November 12, 2023, 6:48pm UTC](https://forums.digi.com/t/digimeshkit-and-python-and-io-as-digital-input-what-to-import-library-etc/28381 "2023-11-12T18:48:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brccd](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@brccd](https://forums.digi.com/u/brccd)\
**Post date:** [November 12, 2023, 6:48pm UTC](https://forums.digi.com/t/digimeshkit-and-python-and-io-as-digital-input-what-to-import-library-etc/28381/1 "2023-11-12T18:48:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brccd](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@brccd](https://forums.digi.com/u/brccd)\
**Post date:** [November 13, 2023, 12:43pm UTC](https://forums.digi.com/t/digimeshkit-and-python-and-io-as-digital-input-what-to-import-library-etc/28381/2 "2023-11-13T12:43:25Z")

</div>

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
