Last active
September 4, 2016 11:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/RyosukeKamei/raspberrypi3.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo python3 led.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment