Sorry my bad. My schematic is the same that the picture I posted in my first message.
Thanks !
#include "FastLED.h"
#define NUM_LEDS 3
#define DATA_PIN 12
CRGB leds[NUM_LEDS];
int R[10] = {0, 0, 0, 0, 0, 255, 255, 255, 255, 255};
int G[10] = {0, 255, 255, 255, 255, 255, 255, 180, 50, 0};
int B[10] = {255, 180, 50, 0, 0, 0, 0, 0, 0, 0};
const int audioPin = A0; // Analog input pin that the audio channel is attached to
const int ledCount = 10; // The number of LEDs in the bar graph
int audioValue; // Analog value read from audio channel
int sensitivityValue = 250;
int ledLevel; // Value to map to the output LEDs
void setup()
{
Serial.begin(9600);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop()
{
int ledPins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
audioValue = analogRead(audioPin);
Serial.println(audioValue);
ledLevel = map(audioValue, 0, 1023, 0, sensitivityValue/2);
if (ledLevel > ledCount) {
ledLevel = ledCount;
}
for (int thisLed = 0; thisLed < ledCount; thisLed++)
{
if (thisLed < ledLevel){
leds[ledPins[thisLed]].setRGB(R[ledPins[thisLed]],G[ledPins[thisLed]],B[ledPins[thisLed]]);
FastLED.show();
delay(10);
}
else{
leds[ledPins[thisLed]].setRGB(0,0,0);
FastLED.show();
delay(10);
}
}
delay(1);
}