LoginSignup
0
0

More than 1 year has passed since last update.

RaspberryPiでLチカ(shellからsysfs経由)

Posted at

やりたいこと

Shell ScriptからSysfsを叩いてLチカします。
今回はGPIO4を操作します。

手順

1.GPIO4を有効にします

cd /sys/class/gpio
echo 4 > export

2.上のコマンドの結果、gpio4というディレクトリができる

cd /sys/class/gpio/gpio4

3.directionを出力に設定します

echo out > direction

4.Highを出力します

echo 1 > value

これでLEDが点灯します。

5.Lowを出力します。

echo 0 > value

これでLEDが消灯します。

6.あとしまつ

cd /sys/class/gpio/
echo 4 > unexport

これでgpio4ディレクトリがなくなります。

0
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
0
0