各位好,下面程序我想改成如动画图片里上面灯带那种方式,请教程序怎样修改,颜色可以不用考虑,谢谢
单片机源程序如下:
- #include <Adafruit_NeoPixel.h>
- #include <FastLED.h>
- #define LED_PIN 9
- #define NUM_LEDS 286
- CRGB leds[NUM_LEDS];
- void setup() {
- FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
- }
- void loop() {
- unsigned int i;
- FastLED.show();
- leds[0] = CRGB(0, 0, 0);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[1] = CRGB(65, 65, 65);
- FastLED.show();
- leds[2] = CRGB(65, 65, 65);
- FastLED.show();
- leds[3] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[4] = CRGB(65, 65, 65);
- FastLED.show();
- leds[5] = CRGB(65, 65, 65);
- FastLED.show();
- leds[6] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[7] = CRGB(65, 65, 65);
- FastLED.show();
- leds[8] = CRGB(65, 65, 65);
- FastLED.show();
- leds[9] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[10] = CRGB(65, 65, 65);
- FastLED.show();
- leds[11] = CRGB(65, 65, 65);
- FastLED.show();
- leds[12] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[13] = CRGB(65, 65, 65);
- FastLED.show();
- leds[14] = CRGB(65, 65, 65);
- FastLED.show();
- leds[15] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[16] = CRGB(65, 65, 65);
- FastLED.show();
- leds[17] = CRGB(65, 65, 65);
- FastLED.show();
- leds[18] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- FastLED.show();
- leds[19] = CRGB(65, 65, 65);
- FastLED.show();
- leds[20] = CRGB(65, 65, 65);
- FastLED.show();
- leds[21] = CRGB(65, 65, 65);
- FastLED.show();
- delay(1000);
- for(i=0;i<24;i++)
- {
- leds[i] = CRGB(0, 0, 0);
- }
- }
复制代码
|