Hello! I am looking into buying a pHAT Stack for one of my projects.
In this forum post, i figured out that it works with any GPIO attachment:
Now I want to how how I can access those GPIO ports in Python code. For example, without the pHAT Stack, you can get input from a button with:
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin and set initial value to be pulled low (off)
while True: # Run forever
if GPIO.input(10) == GPIO.HIGH:
print("Button was pushed!")
How can this be done if this button was connected to pin 10 of one of the 40 pins on the pHAT Stack?
Any help is appreciated, Thanks!