-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcycle.py
More file actions
41 lines (33 loc) · 720 Bytes
/
cycle.py
File metadata and controls
41 lines (33 loc) · 720 Bytes
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
from machine import Pin
from neopixel import NeoPixel
import time
# Translated from Tim Bartlett's arduino code
# https://github.com/timpear/NeoCandle
NUM_PIXELS = 9
red = 255
grn = 100
blu = 10
rd = 1
gd = 3
bd = 5
pin = Pin(0, Pin.OUT) # D3 on nodemcu
np = NeoPixel(pin, NUM_PIXELS)
def setall(r, g, b):
for i in range(NUM_PIXELS):
np[i] = (r, g, b)
np.write()
while True:
red = (red + rd)
if red > 255 or red < 0:
rd = -1*rd
red = red + rd
grn = grn + gd
if grn > 255 or grn < 0:
gd = -1*gd
grn = grn + gd
blu = blu + bd
if blu > 255 or blu < 0:
bd = -1*bd
blu = blu + bd
setall(red, grn, blu)
time.sleep(.01)