And the arduino side:
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
int pinCS = 10;
int numberOfHorizontalDisplays = 8;
int numberOfVerticalDisplays = 2;
int amplitude[64] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
boolean Cleared = true;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
void setup() {
matrix.fillScreen(LOW);
matrix.write();
matrix.setIntensity(15);
matrix.setRotation(0, 1);
matrix.setRotation(1, 1);
matrix.setRotation(2, 1);
matrix.setRotation(3, 1);
matrix.setRotation(4, 1);
matrix.setRotation(5, 1);
matrix.setRotation(6, 1);
matrix.setRotation(7, 1);
matrix.setRotation(8, 1);
matrix.setRotation(9, 1);
matrix.setRotation(10, 1);
matrix.setRotation(11, 1);
matrix.setRotation(12, 1);
matrix.setRotation(13, 1);
matrix.setRotation(14, 1);
matrix.setRotation(15, 1);
Serial.begin(115200);
delay(1000);
}
void loop() {
if(Serial.read() == ('M')){
for(int j=0; j<64; j++){
amplitude[j]=Serial.parseInt();
}
}
if(Serial.read()=='\n'){
matrix.fillScreen(LOW);
for (int x = 0; x<matrix.width(); x++){
int temp = amplitude[x];
matrix.drawLine(x, 16, x, 16 - temp, HIGH);
}
matrix.write();
for (int a = 0; a<64; a++){
amplitude[a] = 0;
}
}
}
I understand that this can be improved by leaps and bounds but I was using this to prototype the system and have run into a problem. If I constraint the freq_height array values to a range of 0 - 8 by reducing the resolution, everything seems to work fine. Alternatively if I reduce the volume on the laptop thereby reducing the overall range of the values in the array things seem to work fine as well.
However as soon as I try to use the full resolution of 16 on max volume such that the freq_array has multiple double digit values the system simply hangs. I can see the last displayed frame on the matrix and that's it. I tried to use the BT module with SoftwareSerial (I do not have a Mega ATM) at a much lower baud rate and can see that the string reaches the Arduino. So I believe that I am parsing the string all wrong. I read through this:
https://forum.arduino.cc/index.php?topic=288234.0
but was unable to adapt the code to parse my incoming data (essentially M followed by 64 comma separated values ending in a new line). Although I can not understand why the above works with relatively small values in the freq_array.
I would really appreciate some help on this since I seem to have reached the end of my intellectual capacity.
Thanks
Nitin