-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpensieve.py
39 lines (29 loc) · 933 Bytes
/
pensieve.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
import time
# Import SPI library (for hardware SPI) and MCP3008 library.
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
# Import libs for video playback
import sys
import os
from subprocess import Popen
# Software SPI configuration
CLK = 11
MISO = 9
MOSI = 10
CS = 8
mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)
print('Reading MCP3008 values, press Ctrl-C to quit...')
# Define the mcp analog input channel. Changes depending on which input connected to on MCP3008.
INPUT_CH = 7
# Define movie location
movie = ('../PensieveMovie.mp4')
# Main program loop
while True:
input_value = mcp.read_adc(INPUT_CH)
if(input_value == 0):
print('No water detected \n')
elif(input_value > 200):
print('Water detected, value: ' + str(input_value))
omxc = Popen(['omxplayer', '-b', '-o', 'local', '--win', '480 270 1440 810', movie])
break
time.sleep(1)