This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
products:sbc:common:applications:gpio:wiringpi [2022/07/04 08:45] frank [Using via Command Line] remove `sudo` |
products:sbc:common:applications:gpio:wiringpi [2023/06/25 23:24] (current) nick |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ===== Introduction ===== | ===== Introduction ===== | ||
| - | This document mainly introduces the WiringPi. You will learn how to use the WiringPi to control the GPIO on the 40-Pin Header. | + | WiringPi is a C++ library for Raspberry Pi, we port it to Khadas SBC, With this library you can use many of the functionalities provided by the GPIO header: digital pins, SPI, I2C, UART, etc. |
| - | + | ||
| - | <WRAP info > | + | |
| - | WiringPi is a C++ library for Raspberry Pi. With this library you can use many of the functionalities provided by the GPIO header: digital pins, SPI, I2C, UART, etc. | + | |
| - | </ | + | |
| ===== WiringPi Instructions ===== | ===== WiringPi Instructions ===== | ||
| Line 20: | Line 16: | ||
| '' | '' | ||
| '' | '' | ||
| - | '' | + | '' |
| - | '' | + | '' |
| ==== Using via Command Line ==== | ==== Using via Command Line ==== | ||
| Line 28: | Line 24: | ||
| * Set GPIO mode to output | * Set GPIO mode to output | ||
| - | ```sh | + | ```shell |
| $ gpio mode 1 out | $ gpio mode 1 out | ||
| ``` | ``` | ||
| * Set output low level | * Set output low level | ||
| - | ```sh | + | ```shell |
| $ gpio write 1 0 | $ gpio write 1 0 | ||
| ``` | ``` | ||
| * Set output high level | * Set output high level | ||
| - | ```sh | + | ```shell |
| $ gpio write 1 1 | $ gpio write 1 1 | ||
| ``` | ``` | ||
| - | ==== Using via C program | + | ==== Using via C Program |
| The test program changes the level value every 5S. | The test program changes the level value every 5S. | ||
| Line 82: | Line 78: | ||
| Compile | Compile | ||
| - | ```sh | + | ```shell |
| $ gcc -o wiringpi wiringpi.c -lwiringPi -lpthread -lrt -lm -lcrypt | $ gcc -o wiringpi wiringpi.c -lwiringPi -lpthread -lrt -lm -lcrypt | ||
| ``` | ``` | ||
| Run | Run | ||
| - | ```sh | + | ```shell |
| sudo ./wiringpi | sudo ./wiringpi | ||
| wPi Pin 1 now is GIGH | wPi Pin 1 now is GIGH | ||