56 lines
889 B
PHP
56 lines
889 B
PHP
|
<?php
|
||
|
|
||
|
require_once __DIR__."/../vendor/autoload.php";
|
||
|
require_once __DIR__."/GLOBALS.php";
|
||
|
|
||
|
/*
|
||
|
* This example demonstrates mapping GpioPins to bit values and writing bits
|
||
|
* in parallel.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
use NoccyLabs\Gpio\Gpio;
|
||
|
use NoccyLabs\Gpio\Util\BitmappedGpio;
|
||
|
use NoccyLabs\Gpio\GpioMapper\WiringPiMapper;
|
||
|
|
||
|
$gpio = new Gpio();
|
||
|
$gpio->setMapper( new WiringPiMapper(2) );
|
||
|
|
||
|
$par = new BitmappedGpio();
|
||
|
for($n = 0; $n < 6; $n++) {
|
||
|
$pin = $gpio[$n]->setDirection("out");
|
||
|
$par->setGpioPin($n,$pin);
|
||
|
}
|
||
|
|
||
|
$aa = array(
|
||
|
0b0000000,
|
||
|
0b0000000,
|
||
|
0b0000000,
|
||
|
0b0000000,
|
||
|
0b0000001,
|
||
|
0b0000011,
|
||
|
0b0000111,
|
||
|
0b0001111,
|
||
|
0b0011110,
|
||
|
0b0111100,
|
||
|
0b1111000,
|
||
|
0b1110000,
|
||
|
0b1100000,
|
||
|
0b1000000,
|
||
|
0b0000000,
|
||
|
);
|
||
|
$ab = array_reverse($aa);
|
||
|
|
||
|
for($x=0;$x<50;$x++) {
|
||
|
foreach($aa as $n) {
|
||
|
$par->write($n);
|
||
|
usleep(50000);
|
||
|
}
|
||
|
foreach($ab as $n) {
|
||
|
$par->write($n);
|
||
|
usleep(50000);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$par->write(0);
|