Skip to content

Instantly share code, notes, and snippets.

@takakabe
Created August 20, 2017 13:13
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 takakabe/126c5015b8220925921af1430eb4a24b to your computer and use it in GitHub Desktop.
Save takakabe/126c5015b8220925921af1430eb4a24b to your computer and use it in GitHub Desktop.
#!/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初期化
@takakabe
Copy link
Author

【RaspberryPi】タクトスイッチでLEDをON/OFFさせてみる
http://kabegiwa.hatenadiary.jp/entry/2017/08/20/222425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment