-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f7b716
commit d5205d2
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
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
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) |