GPIO.add.event.detect alternative for Automation Hat input

I´m new newbie in programming Automation Hat in Python, and I would like to know how/or with replace GPIO.add.event.detect command in my python program? I have set some def and I want callback this event when I press button connected to Hat input.
I try while cycle, but this is unsuitable for me, because I want get signal just once to def.
I want something like this when I using GPIO:

def pressbutton(channel):
my def subprogram

Using RPi.GPIO directly is the best way, you can find the GPIO pin for various inputs here:

Thank you for your replying.
I try use directly GPIO, but I cant set GPIO and automation hat at the same time to one .py, or is it some way how to set using GPIO together with AutomationHat commands?
When I run program I get error:
Traceback (most recent call last):
File “”, line 20, in program
File “”, line 30, in AutomationHat
File “/usr/lib/python2.7/dist-packages/automationhat/”, line 230, in on
File “/usr/lib/python2.7/dist-packages/automationhat/”, line 273, in write
File “/usr/lib/python2.7/dist-packages/automationhat/”, line 259, in setup
File “/usr/lib/python2.7/dist-packages/automationhat/”, line 343, in setup
ValueError: A different mode has already been set!

Ooh, looks like you’ve found a bug with Automation HAT’s deferred loading. I’ll have to catch that error and ignore it.

For the time being, rather than calling GPIO.setmode(GPIO.BCM) in your user code, you could run automationhat.setup()

Actually you should only see this error if you’re using a mode other than GPIO.BCM, if you just use BCM it’ll go away.

The modes are not compatible with each other, so you can’t use BOARD pin numberings while Automation HAT uses GPIO or Automation HAT will get confused about what pins it’s accessing.

1 Like

Great, when I changed to BCM, .py run correct.
Thank you.