-
Notifications
You must be signed in to change notification settings - Fork 776
/
Copy pathCircadian_Pi_Desk_Light.py
53 lines (41 loc) · 1.14 KB
/
Circadian_Pi_Desk_Light.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# SPDX-FileCopyrightText: 2019 Mikey Sklar for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import datetime
import time
import board
import neopixel
pi_pin = board.D18
numpix = 144
brightness = 1.0
pixels = neopixel.NeoPixel(pi_pin, numpix, brightness=brightness)
# morning BLUE light hours
# BLUE light is stimulating
start_morning = "06:00:00"
end_morning = "10:00:00"
# evening RED light hours
# RED light is calming allows melatonin production to increase
start_night = "18:00:00"
end_night = "22:00:00"
color_change = False
while True:
date_string = datetime.datetime.now().strftime("%H:%M:%S" )
if date_string == start_morning:
color = (0, 0, 255)
color_change = True
elif date_string == end_morning:
color = (0, 0, 0)
color_change = True
elif date_string == start_night:
color = (255, 0, 0)
color_change = True
elif date_string == end_night:
color = (0, 0, 0)
color_change = True
else:
time.sleep(1)
# update neopixel strip with new colors
if color_change:
pixels.fill(color)
color_change = False
time.sleep(1)