標(biāo)題: 請(qǐng)教WS2812單片機(jī)程序問(wèn)題 [打印本頁(yè)]

作者: dj3365191    時(shí)間: 2022-2-9 12:49
標(biāo)題: 請(qǐng)教WS2812單片機(jī)程序問(wèn)題
各位好,下面程序我想改成如動(dòng)畫圖片里上面燈帶那種方式,請(qǐng)教程序怎樣修改,顏色可以不用考慮,謝謝

單片機(jī)源程序如下:
  1. #include <Adafruit_NeoPixel.h>
  2. #include <FastLED.h>
  3. #define LED_PIN     9
  4. #define NUM_LEDS    286

  5. CRGB leds[NUM_LEDS];
  6. void setup() {
  7. FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  8. }
  9. void loop() {
  10. unsigned int i;

  11.   FastLED.show();
  12.   leds[0] = CRGB(0, 0, 0);
  13.   FastLED.show();
  14.   delay(1000);

  15.   FastLED.show();
  16.   leds[1] = CRGB(65, 65, 65);
  17.   FastLED.show();
  18.   leds[2] = CRGB(65, 65, 65);
  19.   FastLED.show();
  20.   leds[3] = CRGB(65, 65, 65);
  21.   FastLED.show();
  22.   delay(1000);

  23.   FastLED.show();
  24.   leds[4] = CRGB(65, 65, 65);
  25.   FastLED.show();  
  26.   leds[5] = CRGB(65, 65, 65);
  27.   FastLED.show();
  28.   leds[6] = CRGB(65, 65, 65);
  29.   FastLED.show();
  30.   delay(1000);

  31.   FastLED.show();
  32.   leds[7] = CRGB(65, 65, 65);
  33.   FastLED.show();  
  34.   leds[8] = CRGB(65, 65, 65);
  35.   FastLED.show();
  36.   leds[9] = CRGB(65, 65, 65);
  37.   FastLED.show();
  38.   delay(1000);

  39.   FastLED.show();
  40.   leds[10] = CRGB(65, 65, 65);
  41.   FastLED.show();  
  42.   leds[11] = CRGB(65, 65, 65);
  43.   FastLED.show();
  44.   leds[12] = CRGB(65, 65, 65);
  45.   FastLED.show();
  46.   delay(1000);

  47.   FastLED.show();
  48.   leds[13] = CRGB(65, 65, 65);
  49.   FastLED.show();  
  50.   leds[14] = CRGB(65, 65, 65);
  51.   FastLED.show();
  52.   leds[15] = CRGB(65, 65, 65);
  53.   FastLED.show();
  54.   delay(1000);

  55.   FastLED.show();
  56.   leds[16] = CRGB(65, 65, 65);
  57.   FastLED.show();  
  58.   leds[17] = CRGB(65, 65, 65);
  59.   FastLED.show();
  60.   leds[18] = CRGB(65, 65, 65);
  61.   FastLED.show();
  62.   delay(1000);

  63.   FastLED.show();
  64.   leds[19] = CRGB(65, 65, 65);
  65.   FastLED.show();  
  66.   leds[20] = CRGB(65, 65, 65);
  67.   FastLED.show();
  68.   leds[21] = CRGB(65, 65, 65);
  69.   FastLED.show();
  70.   delay(1000);

  71.   for(i=0;i<24;i++)
  72.   {
  73.   leds[i] = CRGB(0, 0, 0);   
  74.   }

  75. }
復(fù)制代碼





作者: dj3365191    時(shí)間: 2022-2-9 13:41
沒(méi)有人知道嗎
作者: dj3365191    時(shí)間: 2022-2-9 16:44
本帖最后由 dj3365191 于 2022-2-10 12:28 編輯


圖片已經(jīng)發(fā)過(guò),不知什么原因沒(méi)有了,再發(fā)一張,我意思就是按圖片里人頭上面的燈帶動(dòng)畫順序修改程序,達(dá)到這個(gè)效果,謝謝,總共有17條燈帶,每條的顏色任意就好,只需一個(gè)人的順序就行。

作者: glinfei    時(shí)間: 2022-2-10 08:39
你這個(gè)是arduino的程序,到那邊板塊問(wèn)比較好。這個(gè)程序就是定義了一串286個(gè)led,leds[NUM_LEDS]每個(gè)單元表示一個(gè)了點(diǎn),通過(guò)leds[i] = CRGB(0, 0, 0);  改變相關(guān)led的顏色,F(xiàn)astLED.show();點(diǎn)亮。你想怎么改呢?
作者: qwettyuio    時(shí)間: 2022-11-9 15:16
dj3365191 發(fā)表于 2022-2-9 16:44
圖片已經(jīng)發(fā)過(guò),不知什么原因沒(méi)有了,再發(fā)一張,我意思就是按圖片里人頭上面的燈帶動(dòng)畫順序修改程序,達(dá)到 ...

你這程序?qū)崿F(xiàn)了嗎,
作者: hhdsdy    時(shí)間: 2022-11-9 17:42
流水燈的效果?如果只是流水燈就很簡(jiǎn)單啊




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1