Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 向后迭代LED时FastLED库不工作_C++_Arduino_Led - Fatal编程技术网

C++ 向后迭代LED时FastLED库不工作

C++ 向后迭代LED时FastLED库不工作,c++,arduino,led,C++,Arduino,Led,我有问题,我的代码运行的w2812b条是正常的,但当我运行的条我得到一个错误 这就是错误所在 /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1443 (xQueueGenericReceive)- assert failed! abort() was called at PC 0x40087f1d on core 1 我试着查找它

我有问题,我的代码运行的w2812b条是正常的,但当我运行的条我得到一个错误

这就是错误所在

/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1443 (xQueueGenericReceive)- assert failed! abort() was called at PC 0x40087f1d on core 1
我试着查找它并改变我的迭代方式,但到目前为止没有任何效果。我已经发现,当我调用showStrip函数时,它在ledDown函数中第一次运行for循环时中断

代码正在上传到一个esp32,但我很确定这与它没有任何关系

任何帮助都将是惊人的

这是我的密码。我目前刚刚注释掉了LedDown函数

#include "FastLED.h"

#define NUM_LEDS 100
#define LEDPIN 26

CRGB leds[NUM_LEDS];


void setup()
{
  // Debug console
  Serial.begin(9600);

  FastLED.addLeds<WS2812B, LEDPIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

void showStrip() {
   FastLED.show();
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
   // FastLED
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}

void loop() {

  LedUp();
  //LedDown();
}

void LedDown() {
  for(int i = NUM_LEDS; i > 1; i--){
    Serial.println(i);
    setAll(0,0,0);
    delay(100);
    if(i < 33){
      setPixel(i,0,0xff,0);
    }else if(i < 63){
      setPixel(i,0xff,0,0);
    }else{
      setPixel(i,0,0,0xff);
    }
    showStrip();
  }
}

void LedUp() {
  for(int i = 0; i < NUM_LEDS; i++){
    setAll(0,0,0);
    delay(20);
    if(i < 30){
      setPixel(i,0,0xff,0);
    }else if(i < 60){
      setPixel(i,0xff,0,0);
    }else{
      setPixel(i,0,0,0xff);
    }

    showStrip();
  }
}
#包括“FastLED.h”
#定义数量为100
#定义LED引脚26
CRGB发光二极管[NUM_发光二极管];
无效设置()
{
//调试控制台
Serial.begin(9600);
FastLED.AddLED(LED,NUM_LED).setCorrection(TypicCalledStrip);
}
void showtrip(){
fasted.show();
}
void setPixel(整数像素,字节红色,字节绿色,字节蓝色){
//禁食
LED[像素]。r=红色;
LED[像素].g=绿色;
LED[像素].b=蓝色;
}
void setAll(字节红色、字节绿色、字节蓝色){
对于(int i=0;i1;i--){
序列号println(i);
setAll(0,0,0);
延迟(100);
如果(i<33){
设置像素(i,0,0xff,0);
}否则如果(i<63){
设置像素(i,0xff,0,0);
}否则{
设置像素(i,0,0,0xff);
}
showStrip();
}
}
void LedUp(){
对于(int i=0;i
您需要从
NUM_LED-1
开始并归零:

for(int i = NUM_LEDS - 1; i >= 0; i--)
因为
NUM_LED
本身超出范围

for(int i = NUM_LEDS - 1; i >= 0; i--)