1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry Pi: pntctrl の使い方

Last updated at Posted at 2025-06-17

こちらを参考にしました。
Raspberry Pi 5 におけるGPIO操作は pinctrl を使う (raspi-gpio後継コマンド)

私は、Raspberry Pi 4 で確認しました。

$ uname -a
Linux dahlia 6.12.25+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux

端子の確認

pinctrl -p

実行結果

$ pinctrl -p
 1: 3v3
 2: 5v
 3: ip    pu | hi // GPIO2 = input
 4: 5v
 5: ip    pu | hi // GPIO3 = input
 6: gnd
 7: op -- pu | lo // GPIO4 = output
 8: ip    pn | hi // GPIO14 = input
 9: gnd
10: ip    pu | hi // GPIO15 = input
11: ip    pd | lo // GPIO17 = input
12: ip    pd | lo // GPIO18 = input
13: ip    pd | lo // GPIO27 = input
14: gnd
15: ip    pd | lo // GPIO22 = input
16: ip    pd | lo // GPIO23 = input
17: 3v3
18: ip    pd | lo // GPIO24 = input
19: a0    pd | lo // GPIO10 = SPI0_MOSI
20: gnd
21: a0    pd | lo // GPIO9 = SPI0_MISO
22: ip    pd | lo // GPIO25 = input
23: a0    pd | lo // GPIO11 = SPI0_SCLK
24: op -- pu | hi // GPIO8 = output
25: gnd
26: op -- pu | hi // GPIO7 = output
27: ip    pu | hi // GPIO0 = input
28: ip    pu | hi // GPIO1 = input
29: ip    pu | hi // GPIO5 = input
30: gnd
31: ip    pu | hi // GPIO6 = input
32: ip    pd | lo // GPIO12 = input
33: ip    pd | lo // GPIO13 = input
34: gnd
35: ip    pd | lo // GPIO19 = input
36: ip    pd | lo // GPIO16 = input
37: ip    pd | lo // GPIO26 = input
38: ip    pd | lo // GPIO20 = input
39: gnd
40: ip    pd | lo // GPIO21 = input

GPIO4 を ON にする

pinctrl -e set 4 op dh

実行結果

$ pinctrl -e set 4 op dh
 4: op -- pu | hi // GPIO4 = output

DSCN0405.JPG

GPIO4 を OFF にする

pinctrl -e set 4 op dl

実行結果

$ pinctrl -e set 4 op dl
 4: op -- pu | lo // GPIO4 = output

GPIO12 を ON にする

pinctrl -e set 12 op dh

DSCN0406.JPG

GPIO12 を OFF にする

pinctrl -e set 12 op dl
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?