Created
August 20, 2017 13:13
-
-
Save takakabe/126c5015b8220925921af1430eb4a24b to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BCM) # 初期設定 | |
GPIO.setup(15,GPIO.OUT) # 出力設定 | |
GPIO.setup(14,GPIO.IN) # 入力設定 | |
# タクトスイッチの状態をもとに判定する | |
# 押す=HIGH はなす=LOW | |
while True: | |
if GPIO.input(14) == GPIO.HIGH: | |
GPIO.output(15,GPIO.HIGH) # LED点灯 | |
else: | |
GPIO.output(15,GPIO.LOW) # LED消灯 | |
GPIO.cleanup() # GPIO初期化 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
【RaspberryPi】タクトスイッチでLEDをON/OFFさせてみる
http://kabegiwa.hatenadiary.jp/entry/2017/08/20/222425