After looking at the link I posted it (seemed) fairly straight forward. So ignore the code above and give this an actual try. See if it does anything. Note the pin to connect to the Neopixels is pin 5, though you can change that. Rather than me explain the options, why don’t you review the code and see what questions you have.
baseline, ver 0.0
#include <math.h>
#include <Adafruit_NeoPixel.h>
// declare the constants
const boolean logMode = false; //enable or disable log mode display
const boolean debug = false; //enable or disable debug measurements and printouts
const byte analogPinL = 0; //left channel analog data from shield
const byte analogPinR = 1; //right channel analog data from shield
const byte strobePin = 4; //data strobe for shield
const byte resetPin = 7; //reset strobe for shield
const byte dataPin = 5; //data pin for Neopixels
const byte numBand = 30; //number of LEDs for each freq band
const byte numTop = 2; //number of LEDs to have top color
const int noise[] = {
0, 0, 0, 0, 0, 0, 0}; //set this to magnitude of noise from shield
const float gain[] = {
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; //gain for each band
const unsigned long loop_dlay = 1; //loop delay to slow down display update rate
Adafruit_NeoPixel strip = Adafruit_NeoPixel(7*numBand, dataPin, NEO_GRB + NEO_KHZ800);
uint32_t off = strip.Color(0, 0, 0);
uint32_t base = strip.Color(0, 255, 0);
uint32_t top = strip.Color(255, 0, 0);
enum audio
{
MONO,
RIGHT,
LEFT
};
// declare the variables
int spectrumReadR; //R magnitude from shield
int spectrumReadL; //L magnitude from shield
int audio = MONO; //set audio mode to mono, combine R&L channels
int mag = 0; //the magnitude of a freq band
int numON = 0; //the number of LEDs on in a freq band
float fl_mag = 0.0; //floating point mag after noise removal and scaling
void setup() {
Serial.begin(9600);
// initialize the digital pins as an outputs.
pinMode(resetPin, OUTPUT);
pinMode(strobePin, OUTPUT);
pinMode(dataPin, OUTPUT);
// set the initial states
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, LOW);
digitalWrite(dataPin, LOW);
//initialize the Neopixels
strip.begin();
strip.show(); // Initialize all pixels to 'off'
//Initialize spectrum analyzer
digitalWrite(resetPin,HIGH);
delayMicroseconds(5);
digitalWrite(strobePin,HIGH);
delayMicroseconds(50); // strobe PW > 18 usec min
digitalWrite(strobePin,LOW);
delayMicroseconds(50); //reset PW > 100 usec min
digitalWrite(resetPin,LOW);
delayMicroseconds(5);
digitalWrite(strobePin,HIGH);
delayMicroseconds(100); // allow reset to strobe falling > 72 usec min
}
void loop() {
//now do the calculations for each freq band
for(byte band = 1; band <= 7; band++){
//bring strobe low to output data
digitalWrite(strobePin,LOW);
delayMicroseconds(40); // allow 36 usec min for output to settle
// data is now available on analog pins 0 and 1
spectrumReadR = analogRead(analogPinR);
spectrumReadL = analogRead(analogPinL);
if(debug){
Serial.print("Right chan reads ");
Serial.print(spectrumReadR);
Serial.print(" for band ");
Serial.println(band);
Serial.print("Left chan reads ");
Serial.print(spectrumReadL);
Serial.print(" for band ");
Serial.println(band);
}
//now set strobe back to high
digitalWrite(strobePin, HIGH);
//combine L/R data as dictated by setting
switch (audio) {
case MONO:
// this averages the L & R readings
mag = (spectrumReadL + spectrumReadR)/2;
break;
case RIGHT:
// this sets the magnitude = R data
mag = spectrumReadR;
break;
case LEFT:
//this sets the magnitude = L data
mag = spectrumReadL;
break;
default:
//this sets the magnitude = L data
mag = spectrumReadL;
break;
}
if(debug){
Serial.print("Magnitude is ");
Serial.println(mag);
}
//now remove "noise" and rescale
mag = max(0,(mag - noise[band-1]));
fl_mag = gain[band-1]*float(mag);
if(debug){
Serial.print("Magnitude after noise removal is ");
Serial.println(fl_mag);
}
//remap signal magnitude in number of LEDs to be on
// take log if mode is set
if(logMode){
//convert to 20log of input
fl_mag = 20.0*log10(fl_mag);
numON = map(fl_mag, 0, 60, 0, 30);
}
else{
numON = map(fl_mag, 0, 1024, 0, 30);
}
if(debug){
Serial.print("Number of LEDs on is ");
Serial.print(numON);
Serial.print(" for band ");
Serial.println(band);
}
//now store color of this bands LEDs into the larger array
for(byte i = 0; i < numBand; i++){
if(i < (numON - numTop - 1)){
strip.setPixelColor(i + numBand*(band-1), base); //set LEDs to base color
}
else if(i >= numON){
strip.setPixelColor(i + numBand*(band-1), off); //set LEDs off
}
else{
strip.setPixelColor(i + numBand*(band-1), top); //set LEDs to top color
}
}
}
if(debug){
Serial.println(" ");
}
//now clock out all 7 bands of data to single Neopixel array
strip.show();
//delay to slow loop rate ~30 Hz
delay(loop_dlay);
}
It compiles for me, see if it works for you.