2017 © Pedro Peláez
 

library gphpio

Library to handle GPIO

image

timesplinter/gphpio

Library to handle GPIO

  • Monday, January 29, 2018
  • by TiMESPLiNTER
  • Repository
  • 0 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

gphpio

This library provides a nice OO interface to interact with the GPIO pins of RaspberryPi (2)., (*1)

Setup

For RaspberryPi (2) please make sure that the files at /sys/class/gpio are owned by root:gpio and that the user which executes the PHP script using this library is also in the group gpio. This should be the case anyway as long as you have already run the raspi-config tool on installation., (*2)

Else you may need to apply the following changes described here., (*3)

Example

The "Hello world" LED-blink script would look like that:, (*4)

$model = new RPi();
$gpio = new GPIO($model);
$pin = 17;

if($gpio->isExported($pin) === false)
    $gpio->export($pin, GPIO::MODE_OUTPUT);

echo 'This is a ' , $model->getName() , PHP_EOL;

for($i = 0; $i < 10; ++$i) {
    $gpio->write($pin, 1);
    echo 'The pin is now: ' , $gpio->read($pin) , PHP_EOL;
    sleep(1);

    $gpio->write($pin, 0);
    echo 'The pin is now: ' , $gpio->read($pin) , PHP_EOL;
    sleep(1);
}

$gpio->unexport($pin);

The Versions

29/01 2018

dev-master

9999999-dev http://github.com/TiMESPLiNTER/gphpio

Library to handle GPIO

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

gpio rpi rpi2 raspberrypi