Skip to content

Commit

Permalink
add four button script
Browse files Browse the repository at this point in the history
  • Loading branch information
sato-makoto committed May 21, 2014
1 parent 7f7b716 commit d5205d2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions four_button/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# check GPIO 28 and 31
# when GPIO is False
# print button pressed
# It will check both GPIO
# for future.


import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

def input_check(port):
button = GPIO.input(port)
return (button, port)

ports = [28, 29, 30, 31]
for port in ports:
GPIO.setup(port, GPIO.IN)

while True:
for port in ports:
check = input_check(port)
if check[0] == False:
if port == ports[0]:
print '赤い釦が押されました'
elif port == ports[1]:
print '白い釦が押されました'
elif port == ports[2]:
print '黄の釦が押されました'
elif port == ports[3]:
print '灰の釦が押されました'
while check[0] == False:
check = input_check(port)

0 comments on commit d5205d2

Please sign in to comment.