User Tools

Site Tools


gpio_control_from_command_line

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gpio_control_from_command_line [2017/01/22 13:58] walkeradmingpio_control_from_command_line [2023/03/09 22:35] (current) – external edit 127.0.0.1
Line 47: Line 47:
 \\  \\ 
 \\  \\ 
-    gpio -readall+    gpio readall
 \\  \\ 
 This will give an output similar to below (This output is from a Pi Zero v1.3) This will give an output similar to below (This output is from a Pi Zero v1.3)
Line 81: Line 81:
 </file> </file>
 \\  \\ 
 +It can be seen that this Pi has GPIO set to OUT and some to IN. I am using the Pi as a clock, so these are the lines going to my LED display. 
 +\\  
 +\\ 
 ---- ----
 ==== Using gpio command ==== ==== Using gpio command ====
 \\  \\ 
 \\  \\ 
 +Before looking at the commands, there is a switch I want to talk about, this is <color red>-g</color>. If you use the -g switch you are operating on BCM numbers, not PIN numbers. I always use BCM numbers, but some people prefer pin numbers.
 +\\ 
 +\\ 
 +To set the function of the GPIO pin, use <color red>gpio -g mode</color>
 +\\ 
 +\\ 
 +    using BCM number
 +    gpio -g mode 18 out - Sets GPIO18 to OUTput mode (GPIO18 is physical pin 12)
 +    
 +    using pin instead of bcm
 +    gpio mode 12 out - Sets GPIO18 to OUTput mode (GPIO18 is physical pin 12)
 +    
 +    Modes are In, Out, PWM, Up, Down and Tri.
 +\\ 
 +\\ 
 +Set GPIO pin to 1 or 0
 +\\ 
 +\\ 
 +    gpio -g write 18 0 - sets GPIO18 to a zero.
 +    
 +    gpio -g write 18 1 - sets GPIO18 to a one.
 +\\ 
 +\\ 
 +
 +----
  
 +    
  
gpio_control_from_command_line.1485093495.txt.gz · Last modified: 2023/03/09 22:35 (external edit)