23 lines
408 B
PHP
23 lines
408 B
PHP
|
<?php
|
||
|
|
||
|
require_once __DIR__."/../vendor/autoload.php";
|
||
|
|
||
|
use NoccyLabs\Linux\Gpio;
|
||
|
|
||
|
try {
|
||
|
$gpio = new Gpio\Gpio();
|
||
|
} catch (Gpio\Exception $e) {
|
||
|
error_log("Error: {$e}");
|
||
|
}
|
||
|
|
||
|
$pin = $gpio->export(0);
|
||
|
$pin->setInterrupt("rising", function() {
|
||
|
echo "Interrupt on GPIO0\n";
|
||
|
});
|
||
|
|
||
|
while(true) {
|
||
|
// We need to call this for our interrupt status to be polled
|
||
|
$gpio->update();
|
||
|
usleep(10000);
|
||
|
}
|