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!