The next thing I wanted to get working with PIO was reading the pin values. I struggled with this until I realized that I needed to initialize the pins and set them to pull_up before starting the state machine. Anyway, here's an example reading all available pins and returning their states on the fifo:
And the output looks like the following. Some of the bits change as I press keys on the keyboard:>>>
MPY: soft reboot
Checking Safety Pin 25...
In Main Now
Couldn't initialize pin: 30
Couldn't initialize pin: 31
MicroPython v1.19.1 on 2022-06-18; Arduino Nano RP2040 Connect with RP2040
Type "help()" for more information.
In Part 3, we'll track the pin states and only output a value when there is a change.
And in Part 4, we'll use an irq to trigger a python function only when there is a key press event so we don't need to keep a cpu core busy watching for button presses.