-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushButton.py
More file actions
36 lines (29 loc) · 746 Bytes
/
PushButton.py
File metadata and controls
36 lines (29 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import RPi.GPIO as GPIO
import sys, select, os
import time
def CheckQuit():
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
line = raw_input()
return 1;
return 0;
GPIO.setmode(GPIO.BCM);
GPIO.setup(17, GPIO.OUT);
GPIO.setup(18, GPIO.IN);
LEDState = 0;
PastPushState = 0;
GPIO.output(17, GPIO.LOW);
while(1):
if CheckQuit(): break;
if GPIO.input(18) and not PastPushState:
print "Push"
if not LEDState:
GPIO.output(17, GPIO.HIGH);
LEDState = 1
print "HIGH"
else:
GPIO.output(17, GPIO.LOW);
LEDState = 0
print "LOW"
PastPushState = GPIO.input(18)
time.sleep(.1);
GPIO.cleanup();