Fade leds with serial communication Arduino

  arduino, arduino-uno, c++, fastled, serial-port

I am getting serial communication and trying to make an led fade effect ,
This is my function for leds which is facing latency issues , obviously the for loop . Can anyone suggest a better logic or solution to approach this without getting latency in leds?

void controlLeds (int note) {
    note -= 1;
    if (!leds[note]) {
        leds[note].red = redVal;
        leds[note].green = greenVal;
        leds[note].blue = blueVal;      
    } 

    else {
   for(int i =0; i<=255; i++){       
       leds[note].fadeToBlackBy(i);
       FastLED.show();
       if(!leds[note]){
        break;       
       }
   }       
      }
   FastLED.show();
}

Source: Windows Questions C++

LEAVE A COMMENT