在Raspberry Pi树莓派上安装PHP库实现控制gpio接口。

jackxiang 2013-9-19 23:42 | |
背景:想用PHP读取并控制温度:https://github.com/ronanguilloux/temperature-pi


https://github.com/ronanguilloux/php-gpio
———————————————————————————————
Installation
这样才对:
root@raspberrypi:~/dev_codes_all/php-gpio-extension# php composer.phar create-project --stability='dev' ronanguilloux/php-gpio php-sources-all
Installing ronanguilloux/php-gpio (dev-master 2ab29290e0fd45992103062bc949c8e18f622a20)
  - Installing ronanguilloux/php-gpio (dev-master master)
    Cloning master
Created project in php-sources-all
Loading composer repositories with package information
Installing dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? y
目录:
root@raspberrypi:~/dev_codes_all/php-gpio-extension/php-sources-all# pwd
/root/dev_codes_all/php-gpio-extension/php-sources-all

root@raspberrypi:~/dev_codes_all/php-gpio-extension/php-sources-all# find . -name "autoload.php"
./vendor/autoload.php

vi ~/dev_codes_all/php-gpio-extension/php-sources-all/testgpio.php
Egg:
<?php
require 'vendor/autoload.php';
use PhpGpio\Gpio;
echo "Setting up pin 17\n";
$gpio = new GPIO();
$gpio->setup(17, "out");
echo "Turning on pin 17\n";
$gpio->output(17, 1);
echo "Sleeping!\n";
sleep(3);
echo "Turning off pin 17\n";
$gpio->output(17, 0);
echo "Unexporting all pins\n";
$gpio->unexportAll();


root@raspberrypi:~/dev_codes_all/php-gpio-extension/php-sources-all# php  testgpio.php
Setting up pin 17
Turning on pin 17
Sleeping!
Turning off pin 17
Unexporting all pins

来源:https://github.com/ronanguilloux/php-gpio

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/6675/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]