2
2

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でLチカ 個人的まとめ

2
Last updated at Posted at 2016-08-02

Vimのコマンド

(C言語使用の場合はwiringPiのインストールが必須)

方法➀ GPIOピンを出力モードに初期化   $gpio -g mode ピン番号 out

  LED点灯   $gpio -g write ピン番号 1
   LED消灯  $gpio -g write ピン番号 0

方法➁ Pythonで記述
1,おまじない #!/usr/bin/python
2,GPIOライブラリのインポート
import RPi.GPIO as GPIO
3,チャンネルの指定
GPIO.setmode(GPIO.BCM)
4,チャンネルのモード設定
GPIO.setup([GPIOピン番号, GPIO.OUT)
5,デジタル出力
GPIO.output([GPIOピン番号, GPIO.True/False)
    
GPIO入力
GPIO.input(GPIOピン番号)

方法➂ C言語で記述
1,wiringPiの初期化
if(wiringPiSetupGpio() == -1) return 1;
2,チャンネルのモード設定
pinMode(GPIOピン番号, OUTPUT/INPUT);
3,出力
digitalWrite(GPIOピン番号, 0/1);

その他は随時追加

ブレッドボード配線

・マイナス端子をラズパイのグランド端子に接続(グラウンド端子は8つしかないので、ブレッドボードのグラウンド線を使用) (画像は、ツール・ラボ第23回 https://tool-lab.com/make/raspberrypi-startup-23/ より)
bb-61.png

・プラス端子をラズパイの3.3V/5V端子に接続

・実体配線図(画像は ツール・ラボ 第17回 https://tool-lab.com/make/raspberrypi-startup-17/ より)
circuit-real.png

・ラズパイ2のGPIOピン配置(画像は、http://elinux.org/File:Pi-GPIO-header.png より)
Pi-GPIO-header.png

2
2
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?