Hello and Welcome! If you have a technical question please check out our Forums. If you have an order or shipping question please refer to our Customer Support page. Please see all COVID-19 updates here and thank you for your continued support.


SparkFun will be closed on Tuesday, November 3rd because we are out voting! Orders placed after 2 pm MT Monday, November 2nd will ship on Wednesday, November 4th.

Member #504988

Member Since: January 3, 2014

Country: United States

  • The code example provided on the product page didn't work for me, but the code found on the top of the forum thread worked like a champ: https://forum.sparkfun.com/viewtopic.php?f=14&t=38253

  • This shield puts the FUN in SparkFun! (Sorry)

    Wanted to share code for newbs like myself who found the examples didn't work quite like I was expecting. This code uses the same board / LED configuration as SF example, but produces more of a peak level meter.

    A good tip from the linked github repository points out that the A0 and A1 pins are reading left and right channels. The code grabs all 7 frequencies from both channels, adds them up, and lights more LEDs the higher the number.

    One code mod to try is lighting all LEDs just on the highest sum which will typically cause the lights to strobe to the beat. You may need to adjust thisSum ranges according to your card / audio source.

    This sketch acts like the old peak level indicators
    on stereo equipment. 
    //Declare Spectrum Shield pin connections
    #define STROBE 4
    #define RESET 6
    #define DC_One A0
    #define DC_Two A1
    int Spectrum[7];
    int thisSum;
    byte Band;
    void setup() {
      //Set LED pin configurations
      pinMode(7, OUTPUT);
      pinMode(8, OUTPUT);
      pinMode(9, OUTPUT);
      pinMode(10, OUTPUT);
      pinMode(11, OUTPUT);
      pinMode(12, OUTPUT);
      pinMode(13, OUTPUT);
      //Set spectrum Shield pin configurations
      pinMode(STROBE, OUTPUT);
      pinMode(RESET, OUTPUT);
      pinMode(DC_One, INPUT);
      pinMode(DC_Two, INPUT);  
      digitalWrite(STROBE, HIGH);
      digitalWrite(RESET, HIGH);
      //Initialize Spectrum Analyzers
      digitalWrite(STROBE, LOW);
      digitalWrite(RESET, HIGH);
      digitalWrite(STROBE, HIGH);
      digitalWrite(STROBE, LOW);
      digitalWrite(RESET, LOW);
    void loop() {
      thisSum = 0;
      // Read in all 7 channels into array
      for(Band=0;Band <7; Band++)
        Spectrum[Band] = (analogRead(0) + analogRead(1) ) >>1; //Read left then right channels then average by dividing by 2
      // Add up the sum of the output
      for(Band=0;Band <7; Band++) {
        thisSum += Spectrum[Band];
      // Light LEDs according to sum
      // Noise level seems to hover just under 550
      if (thisSum > 550) { digitalWrite(7, HIGH); } else { digitalWrite(7, LOW); }
      if (thisSum > 600) { digitalWrite(8, HIGH); } else { digitalWrite(8, LOW); }
      if (thisSum > 700) { digitalWrite(9, HIGH); } else { digitalWrite(9, LOW); }
      if (thisSum > 800) { digitalWrite(10, HIGH); } else { digitalWrite(10, LOW); }
      if (thisSum > 900) { digitalWrite(11, HIGH); } else { digitalWrite(11, LOW); }
      if (thisSum > 1000) { digitalWrite(12, HIGH); } else { digitalWrite(12, LOW); }
      if (thisSum > 1100) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); }

No public wish lists :(