PYNQ: PYTHON PRODUCTIVITY

Help Accessing Arduino GPIO

Board: PYNQ-Z1
SD Ver: 2.5.1

I am bit confused on accessing the Arduino GPIO pins. I tried using the Python Libraries, but I am having better luck with the Microblaze Library.

I tried this code:

from pynq.lib import MicroblazeLibrary
lib = MicroblazeLibrary(base.iop_arduino, [‘gpio’])

pin41 = lib.gpio_open(41)
lib.gpio_set_direction(pin41,lib.GPIO_OUT)
lib.gpio_write(pin41,1)

pin40 = lib.gpio_open(40)
lib.gpio_set_direction(pin40,lib.GPIO_OUT)
lib.gpio_write(pin40,1)

I am not reading anything above 0.1 V on my DMM. Is there a basic example that shows how to write to a pin? Any help would be appreciated. Thanks!

The easiest way is to use the Arduino_IO class. However, I think your problem is related to your designated pin numbers, because Arduino_IO only supports digital pins 0…13 and analog pins 0…5. So if you absolutely need to use those high-index GPIO pins, then you’re out of luck as I can only find 20 of the Arduino header pins accessible using the pynq API.