import machine, neopixel,time
np = neopixel.NeoPixel(machine.Pin(13), 256)
#驱动接口
'''mode = int(input("请输入模式编号:"))
if mode == 1:
color = (0,255,0)
print("状态正常,亮绿灯",color)
elif mode == 2:
color = (255,255,0)
print("状态警告,亮黄灯",color)
else:
color = (188,114,127)
print("状态故障,亮西瓜红灯",color)
count = 0
while count < 3: # 只要 count 小于 3,就一直重复执行下面缩进的代码
print("闪烁第", count, "次")
# 每次让 count 加 1,否则会永远停不下来
for i in range(256):
if i % 16==0:
continue
np[i] = color
np.write()
time.sleep(0.01)
for i in range(256):
np[i] = (0,0,0)
np.write()
time.sleep(0.01)
count = count+1
#驱动接口'''
'''color_list =[(0,255,0),(255,255,0),(0,0,255),(255,104,99),(37,255,99),(50,200,33),(104,104,70)]
color_list.append((188,114,127))
for c in color_list:
np.fill(c)
np.write()
time.sleep(0.5) '''
'''# 用 16 行字符串画出爱心图纸(每行 16 个字符,0=灭,1=亮红灯)
heart = [
"0000000000000000",
"0000000000000000",
"0001110000111000",
"0011111001111100",
"0111111111111110",
"0111111111111110",
"0111111111111110",
"0111111111111110",
"0011111111111100",
"0001111111111000",
"0000111111110000",
"0000011111100000",
"0000001111000000",
"0000000110000000",
"0000000000000000",
"0000000000000000"
]
for y in range(16):
for x in range(16):
index = y * 16 + x
if heart[y][x] == "1": # 注意这里判断的是字符 "1"(带引号)
np[index] = (255,104,99) # 也可以换成你的西瓜红 (188, 114, 127)
else:
np[index] = (0,0,255)
np.write()
'''
# 16x16 双色笑脸图纸(0=灭,1=黄色脸蛋,2=白色眼睛和嘴巴)
smile = [
"0000011111100000",
"0001111111111000",
"0011111111111100",
"0111111111111110",
"0111221111221110",
"1111221111221111",
"1111111111111111",
"1111111111111111",
"1111111111111111",
"1112111111112111",
"1111211111121111",
"0111122222211110",
"0111111111111110",
"0011111111111100",
"0001111111111000",
"0000011111100000"
]
for y in range(16):
for x in range(16):
index = y * 16 + x
if smile[y][x] == "1":
np[index] = (255, 200, 0) # 温暖的向日葵黄(脸蛋)
elif smile[y][x] == "2":
np[index] = (255, 255, 255) # 纯白色(眼睛和微笑)
else:
np[index] = (0, 0, 0) # 黑色背景
np.write()
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4