Very often people talk about "turn something on/off" with a RaspberryPi, but you can only very rarely find something useful about reading inputs from other systems. So whenever you want to read an input a lot solutions in the web explain ways how to read a GPIO-pin of the RaspberryPi by using a loop (like while (true)), always reading one single pin every few milliseconds and if the state suddenly changes, an event is triggered.
But by using interrupts, there are a lot more possibilities and nicer code as I would like to explain here in the next stepts. I used the python GPIO-lib to activate and react on interrupts on one pin in a short python script.
I also install the wiringPi lib, because that makes live way easier to verify and test on port-pins of the Pi, but the lib is not neccessary for running interrupts on the RaspberryPi.
This last command will fetch an updated version (if not just cloned) then the build script below could be run.
The intention here is to permanently pull the pin to a high level, so whenever something will turn this pin to ground, the interrupt shall be triggert at a later point.
Probably also the mode should be explained, here GPIO.BCM is used. The GPIO.BCM option means that the setup is referring to the pins by the "Broadcom SOC channel" number, these are the numbers of the "GPIO" and not the physical PIN numbers.
The alternative GPIO.BOARD option specifies that the setup is referring to the pins by the number of the pin of the plug - i.e the numbers printed on the board (e.g. P1).
The observed pin 25 is currently on high, as the internal pull-up resistor is activated. Whenever this pin is turned to ground there is a falling slope from high to low. Whenever this happens, the interrupt routine "interrupt_routine" is called.
If the grounding is removed again, the pullup resistors pulls the pin back to high level and nothing happens until the pins is pulled down to ground again.
print time.strftime("%d.%m.%Y %H:%M:%S"), "Just doing nothing, awaiting an interrupt..."
print "Exception thrown -> Abort"