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 笔记》

下图是 Orange Pi 3 的 GPIO 引脚功能图

 《Orange Pi 3 GPIO 笔记》

《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

《Orange Pi 3 GPIO 笔记》

 

 编译运行

gcc -Wall -o test test.c -lwiringPi
sudo ./test

 

劝君别买OrangePi

《Orange Pi 3 GPIO 笔记》
《Orange Pi 3 GPIO 笔记》

 

点赞
  1. I simply wanted to thank you so much once more. I am not sure the things that I would've made to happen without those ways shown by you relating to this topic. This was the troublesome situation in my view, nevertheless witnessing your well-written way you treated the issue took me to weep with joy. Now i am thankful for your work as well as wish you recognize what an amazing job your are undertaking training the rest with the aid of your websites. Probably you haven't met any of us.

发表评论

邮箱地址不会被公开。 必填项已用*标注

You must enable javascript to see captcha here!