树莓派进阶之路 (006) - 树莓派安装wiringPi
安装git-core
sudo apt-get install git-core
下载winringPi库
git clone git://git.drogon.net/wiringPi
编译和安装库
cd wiringPi
./build
另外大家可以使用下面的命令对库进行更新
cd wiringPi
git pull origin
检测是否安装成功:
gpio -v
#!/bin/bash cd / echo "安装git-core" sudo apt-get install git-core echo "下载winringPi库" git clone git://git.drogon.net/wiringPi echo "编译和安装库" cd wiringPi sudo ./build echo "另外大家可以使用下面的命令对库进行更新" cd wiringPi sudo git pull origin echo "版本检查" gpio -v
如果出现错误, 可以先升级下Raspbian:
sudo apt-get update
sudo apt-get upgrade
使用GIT安装WiringPi
git clone git://git.drogon.net/wiringPi
如果出现
Cloning into ‘wiringPi’…
fatal: unable to connect to git.drogon.net:
git.drogon.net: Name or service not known
作者给出的解释是:the most likely cause is that your work/school/college/university/palace firewall is blocking GIT. A lot do for some reason.
大概是GIT被防火墙屏蔽了, 然后作者建议使用Plan B: 从 https://git.drogon.net/?p=wiringPi;a=summary 下载最新版, 然后
tar xfz wiringPi-98bcb20.tar.gz cd wiringPi-98bcb20 ./build
有些麻烦, 没用它, 在stackoverflow上发现用 https:// 代替 git:// 效果不错, 于是在GitHub上找到WiringPi的地址: https://github.com/WiringPi/WiringPi ,然后使用以下命令下载到当前目录(/home/pi):
git clone https://github.com/WiringPi/WiringPi
下载完后, 切换到WiringPi文件夹:
cd WiringPi
运行build脚本自动编译安装:
./build
完成后会给出提示:
NOTE: To compile programs with wiringPi, you need to add:
-lwiringPi
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
-lwiringPiDev
to your compile line(s).
测试WiringPi的安装
输入命令 gpio -v
查看版本信息:
输入命令 gpio readall
读取所有的GPIO的状态:
==========================================================================================================================
树莓派40Pin引脚针脚定义图 GPIO对照表 GPIO库 API 兼容26P
GPIO库:
- wiringPi C,有Perl, PHP, Ruby, Node.JS和Golang的扩展,支持wiringPi Pin和BCM GPIO两种编号
- RPi.GPIO Python,支持Board Pin和BCM GPIO两种编号
- Webiopi,Python, 使用BCM GPIO编号
- WiringPi-Go, Go语言,支持以上三种编号