← 返回命令列表

Linux command

gpio 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Read GPIO pin state

gpio read [pin]

Set GPIO pin output

gpio write [pin] [0|1]

Set pin mode

gpio mode [pin] [in|out|pwm]

Read all pins

gpio readall

Export pin for user access

gpio export [pin] [in|out]

Unexport pin

gpio unexport [pin]

说明

gpio is the WiringPi command-line utility for controlling GPIO pins on Raspberry Pi and similar boards. It allows reading, writing, and configuring GPIO pins from shell scripts and the command line. The tool supports multiple pin numbering schemes: WiringPi numbering (default), BCM GPIO numbering (-g), and physical pin numbers (-1). The readall command displays a complete pin status table.

参数

read _pin_
Read pin value.
write _pin_ _value_
Write value (0 or 1) to pin.
mode _pin_ _mode_
Set pin mode: in, out, pwm, clock.
readall
Display all GPIO pins status.
export _pin_ _mode_
Export pin for user-space access.
unexport _pin_
Unexport pin.
pwm _pin_ _value_
Set PWM value (0-1023).
-g
Use BCM GPIO numbering.
-1
Use physical pin numbering.

FAQ

What is the gpio command used for?

gpio is the WiringPi command-line utility for controlling GPIO pins on Raspberry Pi and similar boards. It allows reading, writing, and configuring GPIO pins from shell scripts and the command line. The tool supports multiple pin numbering schemes: WiringPi numbering (default), BCM GPIO numbering (-g), and physical pin numbers (-1). The readall command displays a complete pin status table.

How do I run a basic gpio example?

Run `gpio read [pin]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does read _pin_ do in gpio?

Read pin value.