3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Pi 2 で pi_piper が動かない→そんなことはなかった

Last updated at Posted at 2015-02-15

なんとなく興味が出てきたので、Raspberry Pi 2 を購入しました。

プログラミングでいう Hello world である LED チカチカに挑戦中です。

シェルスクリプト、Ruby でファイルアクセスによる GPIO 制御がなんとなくわかったきたので gem を使いたいなと思い検索。

pi_piper というものがあるそうなのでそれを以下に従ってやってみた
http://kingyo-bachi.blogspot.jp/2013/07/raspberry-pirubyled.html

でもエラーが出ないのにうまくいかない。

もしかして Raspberry Pi 2 には対応してないんだろうか?
多分自分が悪いとは思うんですが、何が悪いかわからない。。。

require 'pi_piper'
 
pin = PiPiper::Pin.new(:pin => 22, :direction => :out)
 
10.times do
  pin.on
  sleep 0.5
  pin.off
  sleep 0.5
end
 
uexp = open("/sys/class/gpio/unexport", "w")
uexp.write(22)
uexp.close

実行時には sudo つけて実行しています。

(追記)
シェルスクリプトやRubyでファイル書き込みによるLEDチカチカは成功しています
どなたかアドバイスをいただけないでしょうか?

(追記)
やはり自分が悪かった。

please note, in the above context "pin" refers to the GPIO number of the Raspberry Pi.
(https://github.com/jwhitehorn/pi_piper)

つまりピン番号じゃなくてGPIO番号を入れろってこと。
GPIO番号入れたら動きました。
ドキュメントはよく読みましょうね。。。

消したいけど同じ間違いをする人が生まれないように残しておきます汗

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?