File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Adafruit PyPortal display of Twin Peaks
2+ # Liz (BlitzCityDIY) for Adafruit Industries MIT License
3+ # Tutorial: https://learn.adafruit.com/twin-peaks-light-reactive-pyportal-picture-frame
4+ import time
5+ import board
6+ from analogio import AnalogIn
7+ from adafruit_pyportal import PyPortal
8+
9+ analogin = AnalogIn (board .LIGHT )
10+
11+ cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ]
12+
13+ laura = (cwd + "/laura.bmp" )
14+
15+ woodsman = (cwd + "/woodsman.bmp" )
16+
17+ gottaLight = (cwd + "/gottaLight.wav" )
18+
19+ pyportal = PyPortal (default_bg = laura )
20+
21+ def getVoltage (pin ): # helper
22+ return (pin .value * 3.3 ) / 65536
23+
24+ while True :
25+
26+ if getVoltage (analogin ) > 0.175 :
27+ pyportal .set_background (laura )
28+ time .sleep (1 )
29+ else :
30+ pyportal .set_background (woodsman )
31+ pyportal .play_file (gottaLight )
32+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments