使用FastLED和Arduino Nano的"Breathing" LED



将此上载到连接到WS2812 led条的Nano只是冻结当前显示并且不启动序列。我可以把其他的例子上传到电路,它们工作得很好。FastLED和Arduino仍然是新的。当我添加for循环时,问题出现了。

int breath;
void loop() { 
// Fade in, Green, ~ 4 seconds
leds[0] = CRGB::Green;
for (int breath = 0; breath >= 255; breath++ ) {
FastLED.setBrightness(breath);
FastLED.show();
delay(15);

}
// Fade out, Aqua, ~8 seconds
leds[0] = CRGB::Aqua;
for (int breath = 255;breath <= 0; breath = breath-1 ) {
FastLED.setBrightness(breath);
FastLED.show();
delay(31);

}
}

问题可能与这一行有关

for (int breath = 255;breath <= 0; breath = breath-1 ) {

你从255开始,你的测试breath<=0永远不会为真,所以for循环立即启动。从<比;这可能是你想要的。>

最新更新