• Hardware
  • reading digital pins from Pd in Python

I'm trying to read pins in Python after setting them in Pd. I have a Python script that just reads the pins using the Adafruit_BBIO library. It works when I'm not running the Pd patch, but not when Pd is running. Is there an issue with using these two things together? I could swear I've done this before, but I can't seem to get it working now.

Thanks,
Colin

import time
import Adafruit_BBIO.GPIO as GPIO

IN = "P9_12"
OUT = "P9_14"

setup BBB GPIO pins

GPIO.setup(IN, GPIO.IN)
GPIO.setup(OUT, GPIO.OUT)
while True:
if GPIO.input("P9_12"): # bela_setDigital17
print("HIGH")
else:
print("LOW")

clean stuff up when you're done

GPIO.cleanup()

Bela takes possess of the pins marked as Bela GPIO pins in the pin diagram. This means that they are all set to inputs while the program is running, so my guess is you can still read them (GPIO.IN) while it is running but not write to them (GPIO.OUT).

Once this issue will be solved, you will be able to pick which Bela digital pins should be handled by the Bela core code and which should not. Till then, you can disable the Bela digital pins from the project settings in the IDE.