欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: ARDUINO點亮WS2812問題,如何延時1秒后再點亮余下的10顆WS2812,不斷循環(huán) [打印本頁]

作者: dj3365191    時間: 2022-1-25 16:45
標題: ARDUINO點亮WS2812問題,如何延時1秒后再點亮余下的10顆WS2812,不斷循環(huán)
以下程序是點亮10顆任意顏色WS2812,我想延時1秒左右后再點亮余下的10顆WS2812,不斷循環(huán),程序該怎樣修改呢?麻煩大佬幫忙指點一下,謝謝。

#include <Adafruit_NeoPixel.h>

/*
  【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  實驗一百三十一:24位 WS2812 5050 RGB LED 內(nèi)置全彩驅(qū)動彩燈 圓形開發(fā)板
  項目三:使用紅色、綠色和藍色三種參數(shù)將任何LED設(shè)置為任何顏色
  Module      UNO
  VCC   ——   5V
  GND  ——   GND
  DI    ——   D6
*/

#include <FastLED.h>
#define LED_PIN     6
#define NUM_LEDS    24
CRGB leds[NUM_LEDS];
void setup() {
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);

}
void loop() {

  leds[0] = CRGB(255, 0, 0);
  FastLED.show();
  delay(500);  
  leds[1] = CRGB(0, 255, 0);
  FastLED.show();
  delay(500);
  leds[2] = CRGB(0, 0, 255);
  FastLED.show();
  delay(500);
  leds[3] = CRGB(150, 0, 255);
  FastLED.show();
  delay(500);
  leds[4] = CRGB(255, 200, 20);
  FastLED.show();
  delay(500);
  leds[5] = CRGB(85, 60, 180);
  FastLED.show();
  delay(500);
  leds[6] = CRGB(50, 255, 20);
  FastLED.show();

delay(500);

  leds[7] = CRGB(255, 0, 0);
  FastLED.show();
  delay(500);  
  leds[8] = CRGB(0, 255, 0);
  FastLED.show();
  delay(500);
  leds[9] = CRGB(0, 0, 255);
  FastLED.show();
  delay(500);
}

作者: lkc8210    時間: 2022-1-25 21:23
同一問題為什么又發(fā)多一次貼子?
"不斷循環(huán)"中想要循環(huán)的是什么?

作者: dj3365191    時間: 2022-1-26 16:39
lkc8210 發(fā)表于 2022-1-25 21:23
同一問題為什么又發(fā)多一次貼子?
"不斷循環(huán)"中想要循環(huán)的是什么?

就是每組不同顏色的10顆燈一起亮,然后與第二組10顆燈交替亮,一直循環(huán)下去
作者: lkc8210    時間: 2022-1-26 17:41
看看這樣行不?

  1. #include <Adafruit_NeoPixel.h>

  2. /*
  3.   【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  4.   實驗一百三十一:24位 WS2812 5050 RGB LED 內(nèi)置全彩驅(qū)動彩燈 圓形開發(fā)板
  5.   項目三:使用紅色、綠色和藍色三種參數(shù)將任何LED設(shè)置為任何顏色
  6.   Module      UNO
  7.   VCC   ——   5V
  8.   GND  ——   GND
  9.   DI    ——   D6
  10. */

  11. #include <FastLED.h>
  12. #define LED_PIN     6
  13. #define NUM_LEDS    24

  14. CRGB leds[NUM_LEDS];
  15. void setup() {
  16.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);

  17. }
  18. void loop() {

  19. unsigned int i;

  20.   leds[0] = CRGB(255, 0, 0);
  21.   FastLED.show();
  22.   delay(500);  
  23.   leds[1] = CRGB(0, 255, 0);
  24.   FastLED.show();
  25.   delay(500);
  26.   leds[2] = CRGB(0, 0, 255);
  27.   FastLED.show();
  28.   delay(500);
  29.   leds[3] = CRGB(150, 0, 255);
  30.   FastLED.show();
  31.   delay(500);
  32.   leds[4] = CRGB(255, 200, 20);
  33.   FastLED.show();
  34.   delay(500);
  35.   leds[5] = CRGB(85, 60, 180);
  36.   FastLED.show();
  37.   delay(500);
  38.   leds[6] = CRGB(50, 255, 20);
  39.   FastLED.show();
  40.   delay(500);
  41.   leds[7] = CRGB(255, 0, 0);
  42.   FastLED.show();
  43.   delay(500);  
  44.   leds[8] = CRGB(0, 255, 0);
  45.   FastLED.show();
  46.   delay(500);
  47.   leds[9] = CRGB(0, 0, 255);
  48.   FastLED.show();
  49.   delay(500);
  50.   
  51.   for(i=10;i<20;i++)
  52.   {
  53.           leds[i] = CRGB(0, 0, 0);          
  54.   }
  55.   FastLED.show();
  56.   
  57.   
  58.   delay(1000);
  59.   for(i=0;i<10;i++)
  60.   {
  61.           leds[i] = CRGB(0, 0, 0);          
  62.   }
  63.   FastLED.show();
  64.   
  65.   leds[10] = CRGB(255, 0, 0);
  66.   FastLED.show();
  67.   delay(500);  
  68.   leds[11] = CRGB(0, 255, 0);
  69.   FastLED.show();
  70.   delay(500);
  71.   leds[12] = CRGB(0, 0, 255);
  72.   FastLED.show();
  73.   delay(500);
  74.   leds[13] = CRGB(150, 0, 255);
  75.   FastLED.show();
  76.   delay(500);
  77.   leds[14] = CRGB(255, 200, 20);
  78.   FastLED.show();
  79.   delay(500);
  80.   leds[15] = CRGB(85, 60, 180);
  81.   FastLED.show();
  82.   delay(500);
  83.   leds[16] = CRGB(50, 255, 20);
  84.   FastLED.show();
  85.   delay(500);
  86.   leds[17] = CRGB(255, 0, 0);
  87.   FastLED.show();
  88.   delay(500);  
  89.   leds[18] = CRGB(0, 255, 0);
  90.   FastLED.show();
  91.   delay(500);
  92.   leds[19] = CRGB(0, 0, 255);
  93.   FastLED.show();
  94.   delay(1000);
  95.   
  96. }
復(fù)制代碼

作者: dj3365191    時間: 2022-1-26 18:25
lkc8210 發(fā)表于 2022-1-26 17:41
看看這樣行不?

好的很感謝,我試驗一下,不懂的地方再向您請教




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