controlling pc fan digital leds

Hi everyone! I just bought a pack of Thermaltake RIING fans and I've discovered they use WS2812B leds, 12 of them for each fan, arranged in a clockwise direction (as you can see from the first attached picture)

I'm experimenting with them and I'm trying to create an audio based vu-meter, but for the moment I'm just emulating the sound.

I would like to ask you which is the best way to proceed, since I would like to be able to light up all the LEDs of the fans (depending on the value from the vu-meter), but not proceeding clockwise for each fan and then to the next one, but rather as showed in the second attached picture (the numbers in red show the order of lighting up)

Any suggestions? thanks!


Let's see your wiring diagram and your code so far.

Here it is:

#include <FastLED.h>


#define NUM_LEDS 36
#define NUM_FANS 3
#define OFFSET 12
#define MAX_VAL_METER 20
#define DATA_PIN 2
#define CLOCK_PIN 12

// Define the array of leds
CRGB leds[NUM_LEDS];
int normal[13]={10,11,0,1,2,3,4,5,6,7,8,9,10};
int reverse[13]={10,9,8,7,6,5,4,3,2,1,0,11,10};
int values[20]={8,3,1,2,17,1,4,7,9,5,7,13,1,4,12,16,14,11,2,14};


void setup() { 
       Serial.begin(9600);
       FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
}
void audioMeter(int currentFan,int counter,int maxVal)
 {  
    int l1=0;
    int l2=0;
    int curCount=0;   
    int offset = 12*currentFan;    
    while(counter<maxVal){    
        l1=normal[curCount];  
        l2=reverse[curCount];    
       
        l1=reverse[curCount];
        l2=normal[curCount];
        
        leds[l1+offset]=CRGB::Blue;
        leds[l2+offset]=CRGB::Blue;
       
        FastLED.show();
       
        curCount++;
        counter++;
       
        if(curCount==6 && counter<maxVal)
        {
          
          audioMeter(currentFan+1,counter,maxVal);
        }
    }  
 }
  
 
void loop() 
{ 
 
  {
   FastLED.clear ();   
   audioMeter(0,0,values[i]);
   delay(10);
  }
}

2 arrays for storing the clockwise and the anticlockwise led disposition, 1 array for emulating the sound value.
Now, I'm asking:

is there a better way to turn all the leds up to the desired step/value?

since turning all of the leds off before preparing them for the next value leads to unnecessaries blinks, is there a good way to go back/forward to a lower/higher value?

Thanks in advance!

Let's see your wiring diagram.

void loop() 
{ 
 
  {
   FastLED.clear ();   
   audioMeter(0,0,values[i]);
   delay(10);
  }
}

Something missing there: what is "i"?

To avoid flickering, don't put FastLED.clear() in loop().

whops, sorry, I was removing some parts from the code and I removed the loop. Here is the missing i:

 for(int i=0;i<20;i++)
  {
   FastLED.clear ();
   
   audioMeter(0,0,values[i]);
   delay(10);
  }

I do know that the FastLED.clear() causes flickering, what could I use instead?

Attached you can find the wiring diagram.
I replaced the fan led strips with rgb leds since they both have 4 pins (and there were no fan symbols in fritzing) which I wired as follows: 5v in, data out, data in, gnd. By data in and out I mean the start and the end of the data channel; I do know that WS2812B have only 3 channel, but these fan leds are wired to have the start and the end of the data channel in one single connector


You need a resistor in series with the first led, e.g. 220~330R, plus a large cap, e.g. 470~1000uF across the power lines to the strip.

Don't replace FastLED.clear() with anything. Why do you think you need to do that?

these fan leds are wired to have the start and the end of the data channel in one single connector

I don't understand what you are saying. Please be more specific. What type of connector?