Skip to content

Commit 55211ba

Browse files
authored
Add code for new guide
1 parent 941c816 commit 55211ba

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

PyPortal_Twin_Peaks/main.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
import displayio
7+
from analogio import AnalogIn
8+
from adafruit_pyportal import PyPortal
9+
10+
analogin = AnalogIn(board.LIGHT)
11+
12+
cwd = ("/"+__file__).rsplit('/', 1)[0]
13+
14+
laura = (cwd+"/laura.bmp")
15+
16+
woodsman = (cwd+"/woodsman.bmp")
17+
18+
gottaLight = (cwd+"/gottaLight.wav")
19+
20+
pyportal = PyPortal(default_bg=laura)
21+
22+
def getVoltage(pin): # helper
23+
return (pin.value * 3.3) / 65536
24+
25+
while True:
26+
27+
if getVoltage(analogin) > 0.175:
28+
pyportal.set_background(laura)
29+
time.sleep(1)
30+
else:
31+
pyportal.set_background(woodsman)
32+
pyportal.play_file(gottaLight)
33+
time.sleep(1)

0 commit comments

Comments
 (0)