|
各位好,下面程序我想改成如動畫圖片里上面燈帶那種方式,請教程序怎樣修改,顏色可以不用考慮,謝謝
單片機源程序如下:
- #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);
- }
- }
復(fù)制代碼
|
|