Install WiringPi and controlling raspberrypi gpio pins with php

WiringPi is a GPIO access library written in C for the BCM2835 used in the Raspberry Pi.

How to download wiring pi?

If you do not have GIT installed, then under any of the Debian releases (e.g. Raspbian), you can install it with:

To obtain WiringPi using GIT

If you have already used the clone operation for the first time, then

To build/install there is a new simplified script:

Get version info of wiring pi

 

Before you get started you should now how & what pins do. Read details on “Special Pin Functions

If you are new to raspberry Pi. You can follow the guide “How to blink a led“.

 

Read value of wiring pi socket number.

Read value of raspberry pi socket number.

Change mode of a pin to “up”

Change mode of a pin to “down”

 

Write value of wiring pi socket number.

Get the detailed stats of gpio pins

According to it, configure GPIO18 (WiringPi Pin 1) in HW PWM Mode using the command shell:

 

Write a value to the PWM module (from 1 to 1023):

 

To remove the configuration of the pin, use:

 

To remove all configurations:

 

How to run gpio commands via php

 

You can see the Wiring Pi Chart

 

wiringPi
Pin
BCM
GPIO
Name Header Name BCM
GPIO
wiringPi
Pin
3.3v 1 | 2 5v
8 R1:0/R2:2 SDA 3 | 4 5v
9 R1:1/R2:3 SCL 5 | 6 0v
7 4 GPIO7 7 | 8 TxD 14 15
0v 9 | 10 RxD 15 16
0 17 GPIO0 11 | 12 GPIO1 18 1
2 R1:21/R2:27 GPIO2 13 | 14 0v
3 22 GPIO3 15 | 16 GPIO4 23 4
3.3v 17 | 18 GPIO5 24 5
12 10 MOSI 19 | 20 0v
13 9 MISO 21 | 22 GPIO6 25 6
14 11 SCLK 23 | 24 CE0 8 10
0v 25 | 26 CE1 7 11
wiringPi
Pin
BCM
GPIO
Name Header Name BCM
GPIO
wiringPi
Pin

 

  • Board Revisions: Please note the differences between board revisions 1 and 2 (R1 and R2 above)

P5: The auxiliary GPIO connector present on Rev. 2 boards only:

 

wiringPi Pin BCM GPIO Name Header Name BCM GPIO wiringPi Pin
5v 1 | 2 3.3v
17 28 GPIO8 3 | 4 GPIO9 29 18
19 30 GPIO10 5 | 6 GPIO11 31 20
0v 7 | 8 0v
wiringPi
Pin
BCM
GPIO
Name Header Name BCM
GPIO
wiringPi
Pin