laxamar/gpiosysv
Composer 安装命令:
composer require laxamar/gpiosysv
包简介
A library for accessing the GPIO pins on a Raspberry Pi without root for clients using SysV message queue and client/server
README 文档
README
A userland (non-root) library for low level access to the GPIO pins on a Raspberry Pi. These pins can be used to control outputs (LEDs, motors, valves, pumps) or read inputs (sensors).
Adapted by laxamar
From AndrewCarterUK
Installing
This release has two components. A server that can be installed via git or composer. A client that uses composer to install and run.
Client (with server as a service with manual installation)
Using composer:
composer require laxamar/gpiosysv
Or:
php composer.phar require laxamar/gpiosysv
The server code is installed in the vendors/laxamar/gpiosysv directory of composer under the service directory and can be installed as below
Server
The server can be downloaded as by git
sudo install_systemd.sh
will install the necessary files in /usr/local/GPIOSysV and install the systemd service
Examples
Setting Output Pins
use Amar\GPIOSysV\GPIOSysVClt; // Create a GPIO object $gpio_obj = GPIOSysVClt::getInstance(); // Set the value of the pin high (turn it on) $success = $gpio_obj->setPinHigh(18); $success = $gpio_obj->setPinLow(18); // Set a series on PINs using BCD $gpio->setPinsBinary($board, CS_PINs); for ($dec = 0; $dec < 8; $dec++) { // echo "Decimal $dec"; $gpio->strobeBinary($dec, LED_PINs, FLASH_PIN, 1, 0, $frequency, true, $error); }
Input Pin
use Amar\GPIOSysV\GPIOSysVClt; // Create a GPIO object $gpio_obj = GPIOSysVClt::getInstance(); // Set the value of the pin high (turn it on) $value = $gpio_obj->getPin(4);
Further Reading
SitePoint published a tutorial about powering Raspberry Pi projects with PHP which used this library and shows a push button example with a wiring diagram.
More Resources
PiPHP maintains a resource directory for PHP programming on the Raspberry Pi.
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-04