我正在尝试通过仅输入秒数来使 Adafruit 的 NEOPIXEL 变暗,但我无法实现平滑过渡,并且最多只能使用 5 秒。而且我无法让它打印当前的亮度。:(
这是我的代码:
#include <Adafruit_NeoPixel.h>
#define PIN 4
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(3, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
double t = 2000;
dimmerByTime(t);
}
void dimmerByTime(int time){
int seq = time / 170;
int b = 100 /seq;
for (int i = 1; i < seq; i++) {
strip.setPixelColor(0, 0, 100, 200);
strip.setPixelColor(1, 0, 100, 10);
strip.setPixelColor(2, 0, 0, 225);
strip.setBrightness(b);
strip.show();
delay(170);
b = b + b;
Serial.println(i);
Serial.println("Brightness @");
Serial.println(b);
}
}
谢谢!