FFT code for audio spectrum analyzer

edited December 2015 in Arduino

Hey, I'm currently making the spectrum analyzer off this website. http://www.instructables.com/id/Arduino-Processing-Audio-Spectrum-Analyzer/ I'm using a different LED screen, Mine is a 16x32 from adafruit. I've changed and got my arduino portion of the code to work but I'm getting an error that I'm unfamiliar with from processing. I read some people had issues with this project trying to upload the code to processing 3 because originally it was programmed on processing 1. Im running 1.5.1.

Any help is much appreciated!

The line of code causing the problem is:

port = new Serial(this, Serial.list()[1],9600); //set baud rate

This is the error I'm receiving:

WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2 Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 1 at Audio_Spectrum_to_Arduino3216_doublebar_pde.setup(Audio_Spectrum_to_Arduino3216_doublebar_pde.java:68) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:662)

Here is the entire code:

                            import ddf.minim.analysis.*;
                            import ddf.minim.*;
                            import processing.serial.*; //library for serial communication

                            Serial port; //creates object "port" of serial class

                            Minim minim;
                            AudioInput in;
                            FFT fft;
                            float[] peaks;

                            int peak_hold_time = 1;  // how long before peak decays
                            int[] peak_age;  // tracks how long peak has been stable, before decaying

                            // how wide each 'peak' band is, in fft bins
                            int binsperband = 5;
                            int peaksize; // how many individual peak bands we have (dep. binsperband)
                            float gain = 40; // in dB
                            float dB_scale = 2.0;  // pixels per dB

                            int buffer_size = 1024;  // also sets FFT size (frequency resolution)
                            float sample_rate = 44100;

                            int spectrum_height = 176; // determines range of dB shown

                            int[] freq_array = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
                            int i,g;
                            float f;


                            float[] freq_height = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};  //avg amplitude of each freq band

                            void setup()
                            {
                              size(200, 200);

                              minim = new Minim(this);
                              port = new Serial(this, Serial.list()[1],9600); //set baud rate

                              in = minim.getLineIn(Minim.MONO,buffer_size,sample_rate);

                              // create an FFT object that has a time-domain buffer 
                              // the same size as line-in's sample buffer
                              fft = new FFT(in.bufferSize(), in.sampleRate());
                              // Tapered window important for log-domain display
                              fft.window(FFT.HAMMING);

                              // initialize peak-hold structures
                              peaksize = 1+Math.round(fft.specSize()/binsperband);
                              peaks = new float[peaksize];
                              peak_age = new int[peaksize];
                            }


                            void draw()
                            {
                            for(int k=0; k<16; k++){
                            freq_array[k] = 0;
                            }

                              // perform a forward FFT on the samples in input buffer
                              fft.forward(in.mix);

                            // Frequency Band Ranges      
                              freq_height[0] = fft.calcAvg((float) 0, (float) 50);
                              freq_height[1] = fft.calcAvg((float) 51, (float) 69);
                              freq_height[2] = fft.calcAvg((float) 70, (float) 94);
                              freq_height[3] = fft.calcAvg((float) 95, (float) 129);
                              freq_height[4] = fft.calcAvg((float) 130, (float) 176);
                              freq_height[5] = fft.calcAvg((float) 177, (float) 241);
                              freq_height[6] = fft.calcAvg((float) 242, (float) 331);
                              freq_height[7] = fft.calcAvg((float) 332, (float) 453);
                              freq_height[8] = fft.calcAvg((float) 454, (float) 620);
                              freq_height[9] = fft.calcAvg((float) 621, (float) 850);
                              freq_height[10] = fft.calcAvg((float) 851, (float) 1241);
                              freq_height[11] = fft.calcAvg((float) 1242, (float) 1600);
                              freq_height[12] = fft.calcAvg((float) 1601, (float) 2200);
                              freq_height[13] = fft.calcAvg((float) 2201, (float) 3000);
                              freq_height[14] = fft.calcAvg((float) 3001, (float) 4100);
                              freq_height[15] = fft.calcAvg((float) 4101, (float) 5600);


                            // Amplitude Ranges  if else tree
                              for(int j=0; j<16; j++){    
                                if (freq_height[j] < 200000 && freq_height[j] > 200){freq_array[j] = 16;}
                                else{ if (freq_height[j] <= 300 && freq_height[j] > 150){freq_array[j] = 15;}
                                else{ if (freq_height[j] <= 250 && freq_height[j] > 125){freq_array[j] = 14;}
                                else{ if (freq_height[j] <= 200 && freq_height[j] > 100){freq_array[j] = 13;}
                                else{ if (freq_height[j] <= 160 && freq_height[j] > 90){freq_array[j] = 12;}
                                else{ if (freq_height[j] <= 150 && freq_height[j] > 75){freq_array[j] = 11;}
                                else{ if (freq_height[j] <= 140 && freq_height[j] > 65){freq_array[j] = 10;}
                                else{ if (freq_height[j] <= 120 && freq_height[j] > 50){freq_array[j] = 9;}
                                else{ if (freq_height[j] <= 50 && freq_height[j] > 45){freq_array[j] = 8;}
                                else{ if (freq_height[j] <= 45 && freq_height[j] > 40){freq_array[j] = 7;}
                                else{ if (freq_height[j] <= 40 && freq_height[j] > 35){freq_array[j] = 6;}
                                else{ if (freq_height[j] <= 35 && freq_height[j] > 30){freq_array[j] = 5;}
                                else{ if (freq_height[j] <= 30 && freq_height[j] > 15){freq_array[j] = 4;}
                                else{ if (freq_height[j] <= 15 && freq_height[j] > 10){freq_array[j] = 3;}
                                else{ if (freq_height[j] <= 10 && freq_height[j] > 5){freq_array[j] = 2;}
                                else{ if (freq_height[j] <= 5 && freq_height[j] >= 1 ){freq_array[j] = 1;}
                                else{ if (freq_height[j] < 1 ){freq_array[j] = 0;}
                              }}}}}}}}}}}}}}}}}

                              //send to serial
                              port.write(0xff); //write marker (0xff) for synchronization

                              for(i=0; i<16; i++){
                                port.write((byte)(freq_array[i]));
                              }
                              //delay(2); //delay for safety
                            }


                            void stop()
                            {
                              // always close Minim audio classes when you finish with them
                              in.close();
                              minim.stop();

                              super.stop();
                            }

Answers

  • Are you sure, that you define the right serial-port?
    You could check with an empty sketch and this code:

    import processing.serial.*;
    printArray(Serial.list());
    

    Does it list your serial-ports? Is arduino really on index 1?
    Not sure about the RXTX-warning, it's been a while since i saw that error and forgot if it was a problem or could be ignored.

  • Thanks for the reply benja, Ill check the ports in the morning when I set it up again. Ill report back and let you know if once I get the port right the RXTX warning is still an issue.

  • |Hey benja, my serial port is COM3

    in the code you posted... does my serial port number go where the * is like this: import processing.serial.[adruino port];

    or does it go in the second line like this:

    printarray(serial.list([arduino port]));

    Also, do I just write 3? or do I write com3? sorry, the concept of passing the information from processing to arduino is a bit over my head.

    Thanks for the help!

  • You have to specify the port-name when you initilize the serial-connection.

    port = new Serial(this, "COM3", 9600);

    Serial.list() will return an array with the names of all available serial-ports on your system. So if you only have one serial-port, you can just use the first entry from that array as your portname:

    port = new Serial(this, Serial.list()[0], 9600);

    That helps, if the name of your serial-port can change (i.e. if you connect the arduino to a different usb-port).

  • Perfect, That worked. However the RXTX issue is still a problem. In my research I've found essentially processing and arduino arent communicating because they are using 2 RXTX libraries. I double checked the guide im following and downloaded the same versions of both programs he was using.. however still nothing.

    Thanks for your help though, you solved 1 of 2 of my final errors..

    The weird thing is this:

    If I run my arduino code it compiles and the uno light turns on. if I run processing a little grey window pops up and whatever audio im playing on my computer skips a hair and then it sounds a little bit like the quality is degraded. this leads me to believe that the signal is being used.

    If I was to run the processing and it was working, because its only doing the FFT and sending the values to my arduino nothing should show up on the run window.

    Its weird.....

  • edited December 2015

    Processing 1.5.1 is very old. In order to keep using it, you gotta hunt for the latest compatible library versions released for it! :|

  • Okay, I have looked. Its pretty hard.

    if I open it in processing 3 It can't find the libraries

    error:

    No library found for ddf.minim.analysis No library found for ddf.minim Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.

    I think those are from minim but Im not sure. I might try copying the library files from 1.5.1. Running out of things to try.

  • I installed minim on processing 3 and now I have no errors. The music still degrades slightly when I hit run on processing.

    My program compiles onto arduino... but no output :(

  • edited December 2015

    In Processing 3 we can choose another path for its sketchbook.
    That way, it doesn't mix up w/ the older Processing's sketchbook paths.
    AFAIK, both Processing 1 & 2 come bundled w/ Minim library already.
    But for the other 95% you're gonna need to chase the 1s compatible w/ v1.5.1.

  • I don't have your hardware, but the processing part seems to work and sends values to the serial-port. Maybe problem is on the arduino side?

  • Heres my arduino part. I changed all the libraries and calls for the LED functions because my LED matrix is different then the one he uses. Like I mentioned above I don't know much about coding between processing and arduino (serial port)

    I basically just checked the Baud rates were the same and switched the serial port after you told me that was one of my silly errors.

    I just wanted to take 1 sec to thank you benja and gotoloop. I appreciate you helping me out.

    #include <Adafruit_GFX.h> // Core graphics library
    #include <RGBmatrixPanel.h> // Hardware-specific library
    
    #define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
    #define LAT A3
    #define OE 9
    #define A A0
    #define B A1
    #define C A2
    
    
    RGBmatrixPanel dotmatrix(A, B, C, CLK, LAT, OE, false);
    
    uint32_t BLACK = dotmatrix.Color333(0,0,1);
    uint32_t GREEN = dotmatrix.Color333(0, 7, 0);
    uint32_t RED = dotmatrix.Color333(7, 0, 0);
    uint32_t YELLOW = dotmatrix.Color333(7, 3, 0);
    uint32_t ORANGE = dotmatrix.Color333(7, 3, 3);
    
    int array[16] =    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int arraytemp[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
    int i, j, k, r;
    
    void setup ()
    {
      Serial.begin(9600);
      dotmatrix.fillScreen(BLACK);
    }
    
    void loop()
    {
      //protocol expects data in format of 17 bytes
      //(xff) as a marker to ensure proper synchronization always
      /*if (!Serial.available()>=17) {
        for(r=0; r<17; r++)
          array[r]=0;
      }
      */
    
      if (Serial.read() == 0xff) {
        for (i = 0; i < 16; i++) {
          array[i] = Serial.read();
    
        }
        //switch case statement
        for (j = 0; j < 16; j++) {
          if (array[j] != arraytemp[j]) {
    
            switch (array[j]) {
              case 0:
                dotmatrix.drawLine(2 * j, 0, 2 * j, 15, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                break;
              case 1:
                dotmatrix.drawLine(2 * j, 0, 2 * j, 15, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawPixel(2 * j, 15, GREEN);
                dotmatrix.drawPixel(2 * j + 1, 15, GREEN);
                break;
              case 2:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 14, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 14, GREEN);
                break;
              case 3:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 13, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 13, GREEN);
                break;
              case 4:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 12, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 12, GREEN);
                break;
              case 5:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 11, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 11, GREEN);
                break;
              case 6:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 10, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 10, GREEN);
                break;
              case 7:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 9, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 9, GREEN);
                break;
              case 8:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 8, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 8, GREEN);
                break;
              case 9:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 7, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 7, GREEN);
                break;
              case 10:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 6, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 6, GREEN);
                break;
              case 11:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
                break;
              case 12:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 4, ORANGE);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 4, ORANGE);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
                break;
              case 13:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 3, ORANGE);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 3, ORANGE);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
                break;
              case 14:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 2, ORANGE);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 2, ORANGE);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
                break;
              case 15:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 1, RED);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 2, ORANGE);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 1, RED);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 2, ORANGE);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
                break;
              case 16:
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
                dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 0, RED);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 2, ORANGE);
                dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 0, RED);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 2, ORANGE);
                dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
                break;
            }
    
            arraytemp[j] = array[j];
    
          }
          //removed sendframe
        }
    
      }
    
      delay(1);
    
    }
    
  • edited December 2015

    @Glassjaw0, I've noticed inside your switch () block that all of its cases got this exactly statement:
    dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);.

    And cases 0 & 1 got dotmatrix.drawLine(2 * j, 0, 2 * j, 15, BLACK);.
    While the rest is: dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);.

    This opens up some gr8 opportunity to shorten your code there! $-)

    1 more thing; you don't need this global declaration: int i, j, k, r;.
    Variables i & j can be locally declared inside their respective loops.
    While k & r don't show up in your code at all! @-)

    W/o further adieu, here's your new tweaked & simplified loop(): O:-)

    void loop() {
      delay(15);
      if (Serial.read() != 0xff)  return;
    
      for (int i = 0; i != 16; array[i++] = Serial.read());
    
      for (int j = 0; j != 16; ++j) {
        const int val = array[j];
        if (val < 0 | val > 16 | val == arraytemp[j])  continue;
        arraytemp[j] = val;
    
        if (val < 2)  dotmatrix.drawLine(2 * j, 0, 2 * j, 15, BLACK);
        else          dotmatrix.drawLine(2 * j, 15, 2 * j, 0, BLACK);
    
        dotmatrix.drawLine(2 * j + 1, 0, 2 * j + 1, 15, BLACK);
    
        switch (val) {
        case 1:
          dotmatrix.drawPixel(2 * j, 15, GREEN);
          dotmatrix.drawPixel(2 * j + 1, 15, GREEN);
          break;
        case 2:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 14, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 14, GREEN);
          break;
        case 3:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 13, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 13, GREEN);
          break;
        case 4:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 12, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 12, GREEN);
          break;
        case 5:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 11, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 11, GREEN);
          break;
        case 6:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 10, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 10, GREEN);
          break;
        case 7:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 9, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 9, GREEN);
          break;
        case 8:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 8, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 8, GREEN);
          break;
        case 9:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 7, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 7, GREEN);
          break;
        case 10:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 6, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 6, GREEN);
          break;
        case 11:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
          break;
        case 12:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 4, ORANGE);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 4, ORANGE);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
          break;
        case 13:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 3, ORANGE);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 3, ORANGE);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
          break;
        case 14:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 2, ORANGE);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 2, ORANGE);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
          break;
        case 15:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 1, RED);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 2, ORANGE);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 1, RED);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 2, ORANGE);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
          break;
        case 16:
          dotmatrix.drawLine(2 * j, 15, 2 * j, 0, RED);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 2, ORANGE);
          dotmatrix.drawLine(2 * j, 15, 2 * j, 5, GREEN);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 0, RED);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 2, ORANGE);
          dotmatrix.drawLine(2 * j + 1, 15, 2 * j + 1, 5, GREEN);
        }
      }
    }
    
  • Hey, Thanks for cleaning that up @gotoloop , apparently i'm going brain dead staring at this. It is making me sloppy. :-O :-O

    I tossed that in my code. The Arduino uploads and when I run processing the RX light comes on. This is aside from the L and on light from plugging the USB in. I think that confirms what @benja said about the serial information being sent.

    Another thing I just noticed is in the original build he was using a nano, while I am using Uno. However, later he states its okay to use an uno or mega. I'm not sure there is any other coding differences for the units aside from their pinouts.

    I'm starting to loose hope a little. I may have bit off more then I can chew with this project.

    Thanks for rewriting that @gotoloop

  • Hey @gotoloop and @benja. I got this to work last night after a few more hours of work and being at the brink of throwing this stuff at the wall. Thanks for you help!

  • How did you solve it? Sorry that we couldn't help you more, but it's hard to debug, if you don't have the same hardware.

  • edited December 2015

    @benja One of my arrays carrying the data to arduino wasn't working because it was incorrect and one of my loops could have been written better and the baud rate I was using was too slow which in tern made the value I was receiving very small.... so even if the array was right, I would have been lucky if 2-3 out of 16 lights to light up per band.. between you, gotoloop, 1 guy on the arduino forum and some hairpulling I got it working.

  • Hey, Im doing the exact same thing as Glassjaw0 and Ive followed all the instructions but still no luck. Im wondering what it is that Glassjaw0 did, I cant seem to get the LED matrix to display anything and when I run the processing code a little grey tab opens up, I tried playing audio on my computer but still nothing. please help!!! Just ask if you need more details, Thanks

  • I'm doing the exact same project ( with adafruit and all and UNO). The arduino and led matrix work, I mess around making it display text and stuff. What does not work is that processing don't seem to be processing anything. I start it, it sync with the arduino ( no serial error), a small windows open and than nothing is displayed on the led Matrix. I messed around with my audio input. but no luck. What input processing is reading? Music played from my PC won't work, Mic either. I tried it on another pc the pother day and I had a Audio device error, and at home I don't, so processing is detecting my sound card. Any idea? Tommy seem to have the same problem, I even tried a Virtual windows 7 machine to see with the issue could be windows 10. Thanks

Sign In or Register to comment.