Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timesplinter/gphpio
https://github.com/timesplinter/gphpio
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/timesplinter/gphpio
- Owner: TiMESPLiNTER
- License: mit
- Created: 2015-06-19T17:17:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T11:21:14.000Z (about 7 years ago)
- Last Synced: 2024-04-23T00:22:50.283Z (10 months ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gphpio
This library provides a nice OO interface to interact with the GPIO pins of RaspberryPi (2).
## 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.Else you may need to apply the following changes [described here](http://www.element14.com/community/message/139528/l/re-piface-digital-2--setup-and-use#139528).
## Example
The "Hello world" LED-blink script would look like that:
```php
$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);
```