Arduino驅動WS2812B流動彩虹效果
1 void rainbow(int wait) { 2 3 for(long firstPixelHue = 0; firstPixelHue < 3*65536; firstPixelHue += 256) { 4 5 for(int i=0; i<strip.numPixels(); i++) { 6 7 int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); 8 9 strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); 10 11 } 12 13 strip.show(); // Update strip with new contents 14 15 delay(wait); // Pause for a moment 16 17 } 18 19 }