php-linux-gpio/examples/basic.php

23 lines
408 B
PHP
Raw Normal View History

2014-06-05 00:20:22 +00:00
<?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);
}