-
Notifications
You must be signed in to change notification settings - Fork 0
/
isr.py
51 lines (42 loc) · 1.02 KB
/
isr.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
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
global positive_edge
positive_edge = 0
global negative_edge
negative_edge = 0
def ISRL2H():
global positive_edge
positive_edge += 1
print("Number of positive edge occurences: ", positive_edge)
GPIO.output(18,1)
time.sleep(1)
GPIO.output(18,0)
time.sleep(2)
def ISRH2L():
global negative_edge
negative_edge += 1
print("Number of negative edge occurences: ", negative_edge)
GPIO.output(23,1)
time.sleep(1)
GPIO.output(23,0)
time.sleep(2)
while True:
GPIO.output(18,1)
time.sleep(2)
GPIO.output(23,1)
time.sleep(2)
GPIO.output(18,0)
time.sleep(2)
GPIO.output(23,0)
time.sleep(2)
ch = input("enter 1 if there is a positive edge and o if there is a negative edge: ")
if ch == '1':
ISRL2H()
elif ch == '0':
ISRH2L()
ip = input("enter yes f you want to exit the program: ")
if ip == 'yes':
break