timesplinter/gphpio 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

timesplinter/gphpio

Composer 安装命令:

composer require timesplinter/gphpio

包简介

Library to handle GPIO

README 文档

README

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.

Example

The "Hello world" LED-blink script would look like that:

$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);

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固