This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
products:sbc:common:applications:gpio:40pin-header [2022/07/08 02:30] hyphop [Control GPIO] |
products:sbc:common:applications:gpio:40pin-header [2023/08/16 06:31] jacobe [Troubleshooting] |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{indexmenu_n> | {{indexmenu_n> | ||
+ | ====== GPIO Header ====== | ||
- | ====== 40-Pin Header ====== | + | ===== GPIO usage examples |
- | ===== Introduction ===== | + | <WRAP important > |
+ | Please make sure that the GPIOs you want to use are not configured as other functions, if they are, you can follow [[products: | ||
+ | </ | ||
- | This document will introduce **how to control | + | When you get the GPIO number, you can follow the steps below to control |
- | ===== Preparation ===== | + | ==== Export GPIO ==== |
- | Before controlling the GPIO, we first need to get to the number of the GPIO. Refer to the table below to find the number value of the GPIO you need to control. | + | ```shell |
+ | $ echo 111 | sudo tee / | ||
+ | ``` | ||
- | <tabbox VIM1> | + | ==== Set-up GPIO direction ==== |
- | ^ GPIO ^ Name ^ Physical | + | We can configure direction as input or output. |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | | + | |
- | | | + | |
- | | 506 | PIN.AO5 | 15 | + | |
- | | 505 | PIN.AO4 | 16 | + | |
- | | | + | |
- | | 502 | PIN.AO1 | 18 | + | |
- | | 503 | PIN.AO2 | 19 | + | |
- | | | + | |
- | <tabbox VIM2> | + | ```shell |
+ | $ echo out | sudo tee / | ||
+ | $ echo in | sudo tee / | ||
+ | ``` | ||
- | ^GPIO ^Name ^Physical | + | ==== Set GPIO value ==== |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 470 | PIN.DV21 | + | |
- | | 471 | PIN.DV22 | + | |
- | | 472 | PIN.DV23 | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | PIN.H4 | + | |
- | | | + | |
- | | 506 | | + | |
- | | 505 | | + | |
- | | | + | |
- | | 502 | | + | |
- | | 501 | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM3/ | + | |
- | + | ||
- | ^GPIO ^Name ^Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 506 | PIN.AO10 | + | |
- | | | + | |
- | | 433 | PIN.H6 | + | |
- | | 434 | PIN.H7 | + | |
- | | | + | |
- | | 497 | | + | |
- | | 496 | | + | |
- | | | + | |
- | + | ||
- | <tabbox VIM4> | + | |
- | {{ : | + | |
- | ^GPIO ^Name ^Pin ^Pin ^Name ^GPIO ^ | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 420 | SPDIFOUT | + | |
- | | | + | |
- | | 491 | PIN.Y7 | + | |
- | | 490 | PIN.Y6 | + | |
- | | | + | |
- | | 413 | PIN.D1 | + | |
- | | 414 | PIN.D2 | + | |
- | | | + | |
- | + | ||
- | <tabbox Edge1> | + | |
- | + | ||
- | ^GPIO ^Name ^Physical | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | 112 | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ===== Control | + | |
- | + | ||
- | When you get the GPIO number, you can follow the steps below to control it. Here will take GPIO number '' | + | |
- | + | ||
- | **Export GPIO:** | + | |
```shell | ```shell | ||
- | $ echo 465 | sudo tee / | + | $ echo 1 | sudo tee / |
+ | $ echo 0 | sudo tee / | ||
``` | ``` | ||
- | **Set GPIO direction: | + | |
- | You can set the direction input or output. | + | ==== Get GPIO value ==== |
```shell | ```shell | ||
- | $ echo out | sudo tee / | + | $ cat / |
- | $ echo in | sudo tee / | + | |
``` | ``` | ||
- | **Set or get GPIO value:** | + | ==== Unexport |
```shell | ```shell | ||
- | $ echo 1 | sudo tee / | + | $ echo 111 | sudo tee / |
- | $ echo 0 | sudo tee / | + | |
- | $ cat / | + | |
``` | ``` | ||
- | **Unexport GPIO:** | + | ==== Troubleshooting ==== |
+ | |||
+ | If you got the similar error below, it means that the PIN you try to export is used for another function, you need to edit [[products:sbc: | ||
```shell | ```shell | ||
- | $ echo 465 | sudo tee / | + | khadas@Khadas: |
+ | tee: / | ||
``` | ``` | ||
+ |