Help with getting around an Arduino bug

Hi
I’ve encountered a really annoying bug in the Arduino IDE that makes my code useless… I’d really appreciate some help with my project and avoiding this bug.
The plan is to make a light for my aquarium with an NodeMCU and addressable RGBW strips. Below are my code and a link the Arduino forum, where I posted about the bug.

Link to arduino forum

#include <BlynkSimpleStream.h>
#include <Adafruit_NeoPixel.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

char auth[] = "MyToken";

#define PIN 2
#define NUMPIXELS 15
#define NUMCOLORS 3

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
BlynkTimer timer;

int maxColorPosition;

int fadeTimer;
int fadeTime = 1000;
int fadeSteps = 100;

double intensity = 0;
double currentIntensity = 0;

int setColor[NUMCOLORS];
double setColorProcent[NUMCOLORS];
int color[NUMCOLORS];
double colorProcent[NUMCOLORS];
double currentColorProcent[NUMCOLORS] = {0, 0, 0};
double fadeStepProcent[NUMCOLORS];
double fadeIntensity;

//---------------------------------------------------------------------------------

void setup() {
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
  strip.begin();
  Blynk.syncAll();
}

void loop() {
  Blynk.run();
  timer.run();
}

//---------------------------------------------------------------------------------

BLYNK_WRITE(V0) {
  setColor[0] = param.asInt();
  return;
}

BLYNK_WRITE(V1) {
  setColor[1] = param.asInt();
  return;
}

BLYNK_WRITE(V2) {
  setColor[2] = param.asInt();
  return;
}

BLYNK_WRITE(V3) {
  calcSetColorProcent();
  calcFadeStep();
  fadeTimer = timer.setTimer(10, setStripFade, 100);
  return;
}

BLYNK_WRITE(V4) {
  intensity = param.asDouble() / 255;
  return;
}

BLYNK_WRITE(V9) {
  for (int i = 0; i < NUMCOLORS; i++) {
    setColorProcent[i] = 0;
  }
  setStripColor();
  return;
}

BLYNK_WRITE(V30) {
  Blynk.virtualWrite(V31, setColorProcent[0]);
  return;
}

//---------------------------------------------------------------------------------

void calcFadeStep() {
  for (int i = 0; i < NUMCOLORS; i++) {
    if (currentColorProcent[i] == setColorProcent[i]) {
      fadeStepProcent[i] = 0;
    } else {
      fadeStepProcent[i] = (setColorProcent[i] - currentColorProcent[i]) / fadeSteps;
    }
  }
  return;
}

void calcMaxColorPosition() {
  int tempMax = 0;
  for (int i = 0; i < NUMCOLORS; i++) {
    if (tempMax < setColor[i]) {
      maxColorPosition = i;
      tempMax = setColor[i];
    }
  }
  return;
}

void calcSetColorProcent() {
  calcMaxColorPosition();
  for (int i = 0; i < NUMCOLORS; i++) {
    setColorProcent[i] = (double)setColor[i]/setColor[maxColorPosition];
  }
}

bool checkColorChange() {
  for (int i = 0; i < NUMCOLORS; i++){
    if (color[i] != setColor[i]) {
      return true;
    }
  }
  return false;
}

bool checkIntensityChange() {
  if (currentIntensity != intensity) {
    return true;
  }
  return false;
}

void setStripColor() {
  for (int i = 0; i < NUMCOLORS; i++) {
    color[i] = setColorProcent[i] * intensity * 255;
    currentColorProcent[i] = (double)color[i] / 255;
  }
  
  for (int i = 0; i < NUMPIXELS; i++) {
    strip.setPixelColor(i, color[0], color[1], color[2]);
  }
  strip.show();
  return;
}

void setStripFade() {
  double temp;
  for (int i = 0; i < NUMCOLORS; i++) {
    temp = setColorProcent[i] - currentColorProcent[i];
    if (abs(temp) < abs(fadeStepProcent[i])) {
      colorProcent[i] = setColorProcent[i];
    } else {
      colorProcent[i] = currentColorProcent[i] + fadeStepProcent[i];
    }
    color[i] = colorProcent[i] * intensity * 255;
    currentColorProcent[i] = (double)color[i] / 255;
  }
  
  for (int i = 0; i < NUMPIXELS; i++) {
    strip.setPixelColor(i, color[0], color[1], color[2]);
  }
  strip.show();
  return;
}

Welcome to the Blynk forum…

Do you have any questions about how Blynk commands work, or what widget to use for a particular purpose… perhaps some assistance with setting up your Local Server?

Those are the types of questions that we try to help with :wink:

And on that note (aside from the fact that I can compile your code without errors)… Why are you using <BlynkSimpleStream.h> for a NodeMCU, shouldn’t you be using <BlynkSimpleEsp8266.h>

You look like you are setup for an Arduino using an ESP for shield… but a NodeMCU is fully capable of the prefered Standalone mode.

As I said it’s an annoying bug. There’s no logic in why, where and when it’s happening. It just is…

And why I’m using SimpleStream; I haven’t gotten my Node yet, so I’m testing my setup with a regular Uno via USB :wink:

That might have been a good thing to mention up front :stuck_out_tongue:

So, since I can’t find an error in the compiler, and I don’t have a RGBW strip to test… and I really don’t understand this “bug” in the first place… I will have to bail on this particular issue. But I will keep watching in case someone else chips in with some brilliance.