如何转动发光二极管

2024-09-10 15:15:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在家里安装一些漂亮的LED灯条。但运行代码后,LED将保持最后一种颜色。所以我将颜色设置为RGB(0,0,0),以便关闭它们。所以我的问题是:他们现在是在用电还是在用电?在

正确的方法是什么?在

我在我的raspberry pi上运行代码,我使用Python。在

我的代码:

import board
import time
import neopixel


# Choose an open pin connected to the Data In of the NeoPixel strip.
pixel_pin = board.D18

# Choose the number of NeoPixels.
num_pixels = 2

# Choose the order of the pixel colors - RGB or GRB.
ORDER = neopixel.RGB 

pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.0, auto_write=False, pixel_order=ORDER)

# Show red.
pixels.fill((255,0,0))
pixels.show()

time.sleep(2)

# Turn them off.
pixels.fill((0,0,0))
pixels.show()

Tags: ofthe代码importboardledtime颜色
1条回答
网友
1楼 · 发布于 2024-09-10 15:15:19

你检查过你的场地了吗?在使用Arduino之前,我曾使用过类似的金属条,由于接地连接缺失,我也遇到过类似的问题。在

这里有一个特定于您所使用的硬件所面临问题的链接。链接讨论了一个基本问题。在

https://forums.adafruit.com/viewtopic.php?f=47&t=81506

相关问题 更多 >