我正在做我的第一个编码项目(没有以前的编码经验)。我有一个WS2812B的LED带,我想连续循环几个LED模式通过
如果我只有led模式序列,它将运行所有的一次,然后陷入最后一个序列(我只想运行20秒)
我怀疑我用了太多而真或用错了。是不是第三个led序列中的while True导致它无法重新启动?我想我也用错了时间=函数
我正在使用一个adafruit饰品M0和Mu来写作,如果这很重要的话
我试着把一切都放在一段时间内:一开始。但是如果我这么做的话,LED根本就不会亮
如果为真:
如果为真: 如果时间=20: 中断
testcol = (255, 255, 255)
ttype=type(testcol)
print(ttype)
#pixels[4] = (testcol)
pixels.show()
colors = {0:(255, 0, 0), 1:(255, 165, 0), 2:(255, 255, 0), 3:(0, 255, 0), 4:(0, 0, 255), 5:(0, 35, 200), 6:(255, 0, 255)}
ccount = len(colors)
#print (ccount)
#print(colors[2])
data = range(0,185)
chunks = [data[x:x+ccount] for x in range(0, len(data), ccount)]
for p in chunks:
n = 0
for subp in p:
print ("this is chunks",p, "subpart", n,":",p[n], colors[n])
wp = p[n]
print ("this is wp:", wp)
color = colors[n]
print(color)
pixels[wp] = (color)
print(p)
pixels.show()
n = n+1
while True:
t = random.randrange(1, 185)
oc = pixels[t]
pixels[t] = (174, 255, 0) #Alitove String modification for GRB
print("LED:", t, "has been twinkled")
pixels.show()
time.sleep(0.2)
pixels[t] = (255, 255, 255)
pixels.show()
time.sleep(0.5)
pixels[t] = oc
pixels.show()
运行check-in Mu返回语法错误,如果time=20:before 3rd led sequence
目前没有回答
相关问题 更多 >
编程相关推荐