# How do you access the pHAT Stack's GPIO?

**URL:** <https://forums.pimoroni.com/t/how-do-you-access-the-phat-stacks-gpio/24961>\
**Category:** Support\
**Created:** [June 12, 2024, 5:07pm UTC](https://forums.pimoroni.com/t/how-do-you-access-the-phat-stacks-gpio/24961 "2024-06-12T17:07:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DylDev](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@DylDev](https://forums.pimoroni.com/u/DylDev)\
**Post date:** [June 12, 2024, 5:07pm UTC](https://forums.pimoroni.com/t/how-do-you-access-the-phat-stacks-gpio/24961/1 "2024-06-12T17:07:58Z")

</div>

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:

> [@Can the pHAT Stack be used with regular GPIO attatchments?](https://forums.pimoroni.com/t/can-the-phat-stack-be-used-with-regular-gpio-attatchments/24753):
>
> I’m considering picking up a Pimoroni pHAT Stack for my robotics project. I would like to know if I can connect a GPIO device to the pins of the pHAT Stack like I would without it. Any input on the topic is appreciated. Also, in case you need to know what type of stuff I would be connecting, take a look at these: [Relay](https://www.amazon.com/dp/B00LW15D1M/?coliid=I3DC70ADT4EU7Y&colid=1MFC0Q8823ISU&psc=1&ref_=list_c_wl_lv_ov_lig_dp_it)[GPS Module](https://www.amazon.com/dp/B084MK8BS2/?coliid=I1MNGS7X6YIZF2&colid=1MFC0Q8823ISU&psc=1&ref_=list_c_wl_lv_ov_lig_dp_it)

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![Shoe](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Shoe](https://forums.pimoroni.com/u/Shoe)\
**Post date:** [June 12, 2024, 7:09pm UTC](https://forums.pimoroni.com/t/how-do-you-access-the-phat-stacks-gpio/24961/2 "2024-06-12T19:09:36Z")

</div>

The pHAT stack duplicates the GPIO header so that more devices can be attached, but it doesn’t create more pins. So, if you want to turn GPIO 10 on then you use the exact same code, and _all_ of the corresponding pins on the different headers go high. The pHAT stack doesn’t create more GPIO pins which you can control individually, all of the headers are direct copies of the GPIO pins on the Raspberry Pi.
