WiringPi

From Orange Pi
Jump to: navigation, search

What is the WiringPi

Wiring Pi is a GPIO library written by Drogon. It is originally for the Raspberry Pi, but Orangepi has modified and adapted it to make it work on the Orange Pi mini/Pi, we call it WiringOP. More example details can be found at http://wiringpi.com/. All these examples can be used directly on the Orange Pi mini/Pi.

How to use WiringPi on the Orange Pi mini/Pi

Download the WiringOP on your Orange Pi mini/Pi.
For Orange Pi mini:

git clone https://github.com/orangepi-xunlong/WiringOP -b orangepimini


For Orange Pi:

git clone https://github.com/orangepi-xunlong/WiringOP -b orangepi

After download, you need direct into the WiringOP directory and run:

chmod +x ./build

And then install the WiringOP:

sudo ./build



Check the Pin definitions in WiringPi

Please use the gpio command in the command line to see the pin definitions:

gpio readall

You will then see this information:

Wiringpi pins.jpg

The simplest program: Blink

Blink is the simplest program to control the I/O pins on the board. Create a file called blink.c with the content:

#include <wiringPi.h>
int main (void)
{
  wiringPiSetup () ;
  pinMode (0, OUTPUT) ;
  for (;;)
  {
    digitalWrite (0, HIGH) ; delay (500) ;
    digitalWrite (0,  LOW) ; delay (500) ;
  }
  return 0 ;
}

Then to compile and run, you would enter below in the command line:

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

To see the output of this, you would need to connect a single LED between CON3-11 and GND with a resistor protecting it. It looks like this:
Wiringpi blink.jpg