Last active
August 21, 2017 12:50
-
-
Save takakabe/20e18ac634552ce539b596802a696f1d to your computer and use it in GitHub Desktop.
RaspberryPi
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) # 出力設定 | |
# pull_up_down=GPIO.PUD_DOWNでプルダウン抵抗を設定 | |
GPIO.setup(14,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) # 入力設定 | |
# タクトスイッチの状態をもとに判定する | |
# 押す=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