Skip to content

Commit 827855b

Browse files
authored
Merge pull request #624 from adafruit/TheKitty-patch-74
Add code for new guide
2 parents 941c816 + f8a6dab commit 827855b

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

PyPortal_Twin_Peaks/main.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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)

0 commit comments

Comments
 (0)