Skip to content

Instantly share code, notes, and snippets.

@RyosukeKamei
Last active September 4, 2016 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyosukeKamei/3c47b3b2e6b94a1c1e4da9340334d003 to your computer and use it in GitHub Desktop.
Save RyosukeKamei/3c47b3b2e6b94a1c1e4da9340334d003 to your computer and use it in GitHub Desktop.
Raspberry Pi 3でpythonを使いLEDを光らせる(Hello World) ref: http://qiita.com/RyosukeKamei/items/79ee090f1b68014241ab
$ git clone https://github.com/RyosukeKamei/raspberrypi3.git
# GPIOを制御するライブラリ
import wiringpi
# タイマーのライブラリ
import time
# LEDを繋いだGPIOの端子番号
led_pin = 23 # 16番端子
# GPIO初期化
wiringpi.wiringPiSetupGpio()
# GPIOを出力モード(1)に設定
wiringpi.pinMode( led_pin, 1 )
# whileの処理は字下げをするとループの範囲になる(らしい)
while True:
# GPIOを3.3VにしてLEDを点灯
wiringpi.digitalWrite( led_pin, 1 )
# 1秒待ち
time.sleep(1)
# GPIOを0VにしてLEDを消灯
wiringpi.digitalWrite( led_pin, 0 )
# 1秒待ち
time.sleep(1)
$ sudo python3 led.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment