-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlongpress_test.py
58 lines (36 loc) · 1.04 KB
/
longpress_test.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#####################################SETUP#######################################
# Standard setup starts
import RPi.GPIO as GPIO, time, os
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN)
import cPickle as pickle
from random import randint
import time
# Standard setup ends
def RCtime (RCpin): ## Setup LDR detection
reading = 0
GPIO.setup(RCpin, GPIO.OUT)
GPIO.output(RCpin, GPIO.LOW)
time.sleep(0.05) # adjust speed of reading
GPIO.setup(RCpin, GPIO.IN)
while (GPIO.input(RCpin) == GPIO.LOW):
reading += 1
return reading
Count = 0
if ( GPIO.input(23) == False ):
Count = 100 ## how many times to play the alarm when triggered (makes sure Ninja Cloud detects it)
#flashled(1.5); ## This is when waiting button press to arm system
while True:
if ( GPIO.input(23) == False ):
if (Count > 0):
print Count
Count = Count - 1
time.sleep(.1)
else:
if (Count > 0):
if (Count > 50):
print "short"
print Count
else:
print "long"
print Count