Franck_Spectrum_Analyzer_MSGEQ7_Arduino_nano_7-Bandesx10Led

bonjour,

je viens vers vous comme je ne suis pas programmeur arduino pour faire une modification a ce programme je veux ajouter un potentiomètre pour faire varié la luminosité de 0 à 255, merci par avance…

voici le code il marche très bien .

#include <Adafruit_NeoPixel.h>

//Analog in A1
#define PIN 4 //6

int strobe = 2; // strobe pins on digital 4
int res = 3; // reset pins on digital 5
int freq[7]; // store band values in this array
int band;
int numLed = 10; // number of LEDs in one band strip 12
//

//

Adafruit_NeoPixel strip = Adafruit_NeoPixel(7*numLed, PIN, NEO_GRB + NEO_KHZ800);

void setup()
{
Serial.begin(115200);
//

// strip.setBrightness (val);
strip.setBrightness(100); // modif luminosité des leds de 0 a 255
strip.begin();
strip.show(); // Initialise tous les pixels sur ‘off’
pinMode(res, OUTPUT); // reset
pinMode(strobe, OUTPUT); // strobe
digitalWrite(res,LOW); // reset low
digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield
}
void readMSGEQ7()
// Function to read 7 band equalizers
{
digitalWrite(res, HIGH);
digitalWrite(res, LOW);
for(band = 0; band <7; band++)
{
digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band
delayMicroseconds(30); //
freq[band] = map(analogRead(1),0,923,0,numLed); // lecture de fréquence de magasin 1023 // analogue=A1
//modif = 0,numLed = led OFF // 1,numLed = ON // A0= (0) , A1= (1)
digitalWrite(strobe,HIGH);
}
}

void setPixel(){
for(int i = 0; i < numLed; ++i){
if(i < freq[0]){
strip.setPixelColor(i,255,0,0);// red for 63 hz
}
else{
strip.setPixelColor(i,0,0,0);
}
if(i < freq[1]){
strip.setPixelColor(i+numLed,255,40,0);// orange for 160hz
}
else{
strip.setPixelColor(i+numLed,0,0,0);
}
if(i < freq[2]){
strip.setPixelColor(i+ 2numLed,255,215,0);// yellow for 400 hz
}
else{
strip.setPixelColor(i+ 2
numLed,0,0,0);
}
if(i < freq[3]){
strip.setPixelColor(i+ 3numLed,0,255,0);//green for 1khz
}
else{
strip.setPixelColor(i+ 3
numLed,0,0,0);
}
if(i < freq[4]){
strip.setPixelColor(i+ 4numLed,0,0,255);//blue for 2.5khz
}
else{
strip.setPixelColor(i+ 4
numLed,0,0,0);
}
if(i < freq[5]){
strip.setPixelColor(i+ 5numLed,75,0,130);// Indigo for 6.25khz
}
else{
strip.setPixelColor(i+ 5
numLed,0,0,0);
}
if(i < freq[6]){
strip.setPixelColor(i+ 6numLed,255,255,255);//violet for 16khz
}
else{
strip.setPixelColor(i+ 6
numLed,0,0,0);
}
}
strip.show();
}
void loop()
{
//

//
readMSGEQ7();
// display values of freqyency on serial monitor for testing purposes
for (band = 0; band < 7; band++)
{
Serial.print(freq[band]);
Serial.print(" ");
}
Serial.println();
setPixel();
delay(20);

}