Reflecting LED Matrix Display

Hi everyone

I am working on a spectrum analyzer and am displaying right and left channel. However, with the way its coded, left and right display in the same way on their individual LED matrices, with the low frequencies on the far left to the high frequencies on the far right.

I want to modify my code to do low → high frequencies on the left channel, and high → low frequencies on the right channel.

Here is my code

//LED Matrix Stuff
#include <LedControl.h>
#include <binary.h>
// inputs: DIN pin, CLK pin, LOAD pin. number of chips
LedControl lc = LedControl(12, 11, 10, 2);

// MSGEQ7 spectrum analyser shield - basic demonstration
int strobe = 4; // strobe pins on digital 4
int res = 5; // reset pins on digital 5
int left[8]; // store band values in these arrays
int right[8];
int band;

void setup ()
{
  //MESGEQ7 setup
   Serial.begin(115200);
   pinMode(res, OUTPUT); // reset
   pinMode(strobe, OUTPUT); // strobe
   digitalWrite(res,LOW); // reset low
   digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield
  //LED Matrix setup
   lc.shutdown(0,false); //turns on the display
   lc.setIntensity(0,0); //maximum brightness, 0-15 
   lc.clearDisplay(0); //clears the display
   lc.shutdown(1,false); //turns on the display
   lc.setIntensity(1,0); //maximum brightness, 0-15
   lc.clearDisplay(1); //clears the display
}
void readMSGEQ7()
// Function to read 7 band equalizers
{
 digitalWrite(res, HIGH);
 digitalWrite(res, LOW);
 for(band=0; band <8; band++)
 {
 digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band 
 delayMicroseconds(1000); // 
 left[band] = analogRead(0); // store left band reading
 right[band] = analogRead(1); // ... and the right
 digitalWrite(strobe,HIGH); 
 }
}
void loop()
{
  readMSGEQ7();
// display values of left channel on matrix
for( band = 0; band < 8; band++)
  {
  if (left[band]>=895) { lc.setRow(1, band, 255); } else //This section defines how many LEDs in a column to light up. Defined as set row due to the orientation of the Matrix. This is for the highest value, and the lights up all eight LEDs
  if (left[band]>=767) { lc.setRow(1, band, 254); } else //7
  if (left[band]>=639) { lc.setRow(1, band, 252); } else //6
  if (left[band]>=511) { lc.setRow(1, band, 248); } else //5
  if (left[band]>=383) { lc.setRow(1, band, 240); } else //4
  if (left[band]>=255) { lc.setRow(1, band, 224); } else //3
  if (left[band]>=127) { lc.setRow(1, band, 192); } else //2
  if (left[band]>=75)  { lc.setRow(1, band, 128); } else //1
  if (left[band]>=0)   { lc.setRow(1, band, 0); }        //0 
  }
// display values of right channel on matrix
for( band = 0; band < 8; band++)
  {
  if (right[band]>=895) { lc.setRow(0, band, 255); } else //This section defines how many LEDs in a column to light up. Defined as set row due to the orientation of the Matrix. This is for the highest value, and the lights up all eight LEDs
  if (right[band]>=767) { lc.setRow(0, band, 254); } else //7
  if (right[band]>=639) { lc.setRow(0, band, 252); } else //6
  if (right[band]>=511) { lc.setRow(0, band, 248); } else //5
  if (right[band]>=383) { lc.setRow(0, band, 240); } else //4
  if (right[band]>=255) { lc.setRow(0, band, 224); } else //3
  if (right[band]>=127) { lc.setRow(0, band, 192); } else //2
  if (right[band]>=75)  { lc.setRow(0, band, 128); } else //1
  if (right[band]>=0)   { lc.setRow(0, band, 0); }        //0 
  }
  delay(25);
  }

Hopefully, as you can tell, the function reads one of the eight data values in the array, right or left, and outputs it to the row that is related to the value in the array. Data value 0 outputs to row 0, value 1 outputs to row 1, and so on through all eight rows, from 0-7. I want the right matrix to take data value 0 and output it to row 7, value 1 to output on row 6, and so on, but I’m not sure how to go about it.

Would love any suggestions to try and get this working.

Hi, can't you just replace each instance of

lc.setRow(0, band, ...

with

lc.setRow(0, 7-band, ...

Paul

PaulRB: Hi, can't you just replace each instance of

lc.setRow(0, band, ...

with

lc.setRow(0, 7-band, ...

Paul

Yes, Paul! Thank you! Sorry I didn't get around to replying sooner, but it did work! I appreciate it.