PHP code example of remithefox / php-gpio

1. Go to this page and download the library: Download remithefox/php-gpio library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

remithefox / php-gpio example snippets


use RemiTheFox\PhpGPIO\Pin;
use RemiTheFox\PhpGPIO\GpioElementInterface;

$pin = new Pin(4, GpioElementInterface::DIRECTION_OUT);

$input = $pin->getValue();

$pin->setValue(true);

$pin->setDirection(GpioElementInterface::DIRECTION_OUT);

use RemiTheFox\PhpGPIO\ParallelDataBus;
use RemiTheFox\PhpGPIO\Pin;
use RemiTheFox\PhpGPIO\GpioElementInterface;

$pinNumbers = [2, 1, 3, 7];
$pins = [];
foreach ($pinNumbers as $pinNumber) {
    $pins[] = new Pin($pinNumber);
}
$bus = new ParallelDataBus($pins, GpioElementInterface::DIRECTION_IN);

$input = $pin->getValue();

$pin->setValue(true);

$pin->setDirection(GpioElementInterface::DIRECTION_OUT);

use RemiTheFox\PhpGPIO\Factory as GpioFactory;
use RemiTheFox\PhpGPIO\GpioElementInterface;

$bus = GpioFactory::createParallelDataBus([2, 1, 3, 7], GpioElementInterface::DIRECTION_IN);
bash
$ composer 
text
 /\-/\
(=^w^=)
 )   (