Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:common:applications:gpio:40pin-header

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:common:applications:gpio:40pin-header [2023/08/16 06:31]
jacobe [Set GPIO value]
products:sbc:common:applications:gpio:40pin-header [2024/08/12 03:08] (current)
william [Troubleshooting]
Line 3: Line 3:
 ====== GPIO Header ====== ====== GPIO Header ======
  
-===== GPIO usage examples =====+====== GPIO usage examples ======
  
 <WRAP important > <WRAP important >
Line 11: Line 11:
 When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number ''465'' as an example. When you get the GPIO number, you can follow the steps below to control it. Here we take GPIO number ''465'' as an example.
  
-==== Export GPIO ====+===== Export GPIO =====
  
 ```shell ```shell
-$ echo 111 | sudo tee /sys/class/gpio/export+$ echo 465 | sudo tee /sys/class/gpio/export
 ``` ```
  
-==== Set-up GPIO direction ====+===== Set-up GPIO direction =====
  
 We can configure direction as input or output. We can configure direction as input or output.
  
 ```shell ```shell
-$ echo out | sudo tee /sys/class/gpio/gpio111/direction # Set GPIO output +$ echo out | sudo tee /sys/class/gpio/gpio465/direction # Set GPIO output 
-$ echo in  | sudo tee /sys/class/gpio/gpio111/direction # Set GPIO input+$ echo in  | sudo tee /sys/class/gpio/gpio465/direction # Set GPIO input
 ``` ```
  
-==== Set GPIO value ====+===== Set GPIO value =====
  
 ```shell ```shell
-$ echo 1 | sudo tee /sys/class/gpio/gpio111/value # Set GPIO output high +$ echo 1 | sudo tee /sys/class/gpio/gpio465/value # Set GPIO output high 
-$ echo 0 | sudo tee /sys/class/gpio/gpio111/value # Set GPIO output low+$ echo 0 | sudo tee /sys/class/gpio/gpio465/value # Set GPIO output low
 ``` ```
  
-==== Get GPIO value ====+===== Get GPIO value =====
  
 ```shell ```shell
-$ cat /sys/class/gpio/gpio111/value # Get GPIO input value+$ cat /sys/class/gpio/gpio465/value # Get GPIO input value
 ``` ```
  
-==== Unexport GPIO ==== +===== Unexport GPIO ===== 
  
 ```shell ```shell
-$ echo 111 | sudo tee /sys/class/gpio/unexport+$ echo 465 | sudo tee /sys/class/gpio/unexport
 ``` ```
  
-==== Troubleshooting ====+===== 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:common:configurations:device-tree-overlay|Device Tree Overlay]] configuration file to set the PIN as normal GPIO. 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:common:configurations:device-tree-overlay|Device Tree Overlay]] configuration file to set the PIN as normal GPIO.
  
 ```shell ```shell
-khadas@Khadas:~$ echo 111 | sudo tee /sys/class/gpio/export +$ echo 465 | sudo tee /sys/class/gpio/export 
 tee: /sys/class/gpio/export: Invalid argument tee: /sys/class/gpio/export: Invalid argument
 ``` ```
  
Last modified: 2023/08/16 06:31 by jacobe