-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
43 lines (35 loc) · 804 Bytes
/
test.py
File metadata and controls
43 lines (35 loc) · 804 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
37
38
39
40
41
42
43
import RPi.GPIO as GPIO
import signal
import time
def end_run(signal, frame):
global keep_running
print("ctrl + c captured, end run")
global active_led
GPIO.output(active_led, GPIO.LOW)
GPIO.cleanup()
keep_running = False
def blink(gpio, is_high):
if is_high:
GPIO.output(gpio, GPIO.HIGH)
else:
GPIO.output(gpio, GPIO.LOW)
# ctrl + c => Stop
signal.signal(signal.SIGINT, end_run)
# config GPIO
GPIO.setmode(GPIO.BCM)
# welcome
print("-------FLEXSO FLOW METER-------")
print("")
print("")
print("\trunning...")
print("")
print("\tpress ctrl + c to stop")
# main loop
keep_running = True
active_led = 17
GPIO.setup(active_led, GPIO.OUT)
while keep_running:
blink(active_led, True)
time.sleep(1)
blink(active_led, False)
time.sleep(1)