32 lines
682 B
PHP
32 lines
682 B
PHP
<?php
|
|
|
|
require_once __DIR__."/../vendor/autoload.php";
|
|
|
|
use NoccyLabs\Gpio\Gpio;
|
|
use NoccyLabs\Gpio\GpioMapper\WiringPiMapper;
|
|
|
|
try {
|
|
$gpio = new Gpio();
|
|
} catch (Gpio\Exception $e) {
|
|
error_log("Error: {$e}");
|
|
}
|
|
|
|
// The mapper translates GPIO to logical pins and vice versa
|
|
$gpio->setMapper( new WiringPiMapper(2) );
|
|
|
|
// Access logical pin 0, since we got a mapper assigned. Otherwise this would
|
|
// be the actual GPIO0 pin.
|
|
$led = $gpio[0]
|
|
->export()
|
|
->setEdge(Gpio::EDGE_NONE)
|
|
->setDirection(Gpio::DIR_OUT)
|
|
->setLabel("LED pin")
|
|
->setValue(0);
|
|
|
|
$x = 0;
|
|
while(true) {
|
|
$x = (int)(!$x);
|
|
$led->setValue($x)->dumpStatus(true);
|
|
usleep(500000);
|
|
}
|