Created
September 23, 2012 16:04
-
-
Save Yi-Tseng/3772143 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
from threading import Thread | |
import RPi.GPIO as GPIO | |
x = 0 | |
def keyListen(): | |
stat = False | |
global x | |
while 1: | |
if GPIO.input(11) and not stat: | |
stat = True | |
print "Hello!" | |
x = x+1 | |
if not GPIO.input(11): | |
stat = False | |
def main(): | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(11,GPIO.IN) | |
#GPIO.setup(1,GPIO.OUT) | |
print "Running!" | |
t = Thread(target = keyListen,args=()) | |
t.start() | |
while 1: | |
cmd = raw_input("Input command(times,LED):\n") | |
if cmd == "times": | |
print x | |
elif cmd == "LED": | |
print "Led" | |
else: | |
print "Error command!" | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment