Orange Pi 3 GPIO 笔记
这是我写过的最水的文章
设备:Orange pi H6,Pi 3
引脚图:
(使用Wiringpi 查看GPIO)
+------+-----+----------+------+---+OrangePiH6+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----++----+---+------+----------+-----+------+ | | | 3.3v | | | 1 || 2 | | | 5v | | | | 122 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | | | 121 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | 0v | | | | 118 | 2 | PWM0 | OFF | 0 | 7 || 8 | 0 | OFF | PL02 | 3 | 354 | | | | 0v | | | 9 || 10 | 0 | OFF | PL03 | 4 | 355 | | 120 | 5 | RxD3 | ALT4 | 0 | 11 || 12 | 0 | OFF | PD18 | 6 | 114 | | 119 | 7 | TxD3 | ALT4 | 0 | 13 || 14 | | | 0v | | | | 362 | 8 | PL10 | OFF | 0 | 15 || 16 | 0 | OFF | PD15 | 9 | 111 | | | | 3.3v | | | 17 || 18 | 0 | OFF | PD16 | 10 | 112 | | 229 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | 0v | | | | 230 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | PD21 | 13 | 117 | | 228 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 227 | | | | 0v | | | 25 || 26 | 0 | OFF | PL08 | 16 | 360 | +------+-----+----------+------+---+----++----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+OrangePiH6+---+------+----------+-----+------+
下图是 Orange Pi 3 的 GPIO 引脚功能图
激活 GPIO 模块
modprobe gpio-sunxi
要安装正确版本 的 WiringOP
要先下载 安装git
apt-get install git-core
下载 wiringop
wiringop是基于wiringpi的适配版本 ,GitHub 地址 https://github.com/orangepi-xunlong/WiringOP
git clone https://github.com/orangepi-xunlong/wiringOP.git
cd WiringOP chmod +x ./build sudo ./build
即可安装 Orange Pi 3版本的 WiringPi
测试是否正常安装
gpio readall
出现引脚图说明正常安装
点亮一个小灯
随便找个地方 新建文件,文件名 test.c
#include <wiringPi.h> int main (void) { int a=122; //gpio口 wiringPiSetup () ; pinMode (a, OUTPUT) ; for (;;) { digitalWrite (a, HIGH) ; delay (500) ; digitalWrite (a, LOW) ; delay (500) ; } return 0 ; }
正极放在 pin 3,pin 3 的 gpio 编号为 122,可以随意更改
阴极放在 GND ,pin 6
编译运行
gcc -Wall -o test test.c -lwiringPi
sudo ./test
劝君别买OrangePi
痴者工良(https://whuanle.cn)