import time
import board
import neopixel

# 设置灯珠数量和引脚
NUM_LEDS = 10
PIN = board.D18

# 创建灯珠对象
pixels = neopixel.NeoPixel(PIN, NUM_LEDS)

# 红色灯珠
RED = (255, 0, 0)

# 循环闪烁
while True:
    # 点亮所有灯珠
    pixels.fill(RED)
    # 等待1秒
    time.sleep(1)
    # 熄灭所有灯珠
    pixels.fill((0, 0, 0))
    # 等待1秒
    time.sleep(1)
    # 点亮所有灯珠
    pixels.fill(RED)
    # 等待1秒
    time.sleep(1)
    # 熄灭所有灯珠
    pixels.fill((0, 0, 0))
    # 等待1秒
    time.sleep(1)
    # 点亮所有灯珠
    pixels.fill(RED)
    # 等待1秒
    time.sleep(1)

原文地址: https://www.cveoy.top/t/topic/mmyn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录