FHT spectrum analyzer with Processing and Arduino

Hello,

I am trying to get the FHT 128 channel spectrum analyzer to work with my arduino but I have some questions… (Here is the link: ArduinoFHT - Open Music Labs Wiki)

  1. I can get the program to load on my arduino… The program will run with no errors and the spectrum analyzer will show up. But the LED on the arduino is still blinking from the example sketch I had loaded on there earlier… Not really sure why.

  2. I am using a mac and I need to change the"COM7" port. How do I know what to change it to?
    I have been messing with the number inside here:

Serial.list()[0]

As stated above, I can get it to run with 0 and also 2 but nothing is coming up on the analyzer.

  1. I have biased the microphone signal to 2.5V and amplified it… Which port do I run the output to? I’m guessing A0? I have looked at the website and the forum but I am not sure how they are getting the signal to the arduino…

Pretty much all these questions boil do to how to get data to come up on the screen…

Here is the code:

/*  FHT_128_channel_analyser.pde

    an open-source display for spectrum analyser
    Copyright (C) 2013  Jürgen Rimmelspacher

    For use with "processing": http://processing.org/

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


final int X_OFFSET  =  40;                     // x-distance to left upper corner of window
final int Y_OFFSET  =  60;                     // y-distance to left upper corner of window
final int BOT_DIST  =  80;                     // distance to bottom line of window
final int COL_WIDTH =   4;                     // column widt
final int Y_DIST    =  64;                     // distance horizontal lines
final int X_DIST    =   5;                     // distance vertical lines
final int X_MAX     = (128+1)*X_DIST+1;        // x-axis lenght
final int Y_MAX     = 256;                     // y-axis lenght
final int X_WINDOW  = X_MAX + 2*X_OFFSET;      // window width
final int Y_WINDOW  = Y_MAX+BOT_DIST+Y_OFFSET; // window height
final int X_ENUM    = 10;
PFont fontA;
color graphColor = color(25, 25, 250);
PFont fontGraph;
import processing.serial.*;
Serial port;
int[] inBuffer = new int[128];

void draw_grid()                               // draw grid an title
{ 
  int count=0;

  background(200);
  stroke(0);
  for (int x=0+X_DIST; x<=X_MAX; x+=X_DIST)    // vertical lines
  {
    if ( X_ENUM == count || 0 == count)
    { 
      line (x+X_OFFSET, Y_OFFSET, x+X_OFFSET, Y_MAX+Y_OFFSET+10);
      count=0;
    }
    else
    {
      line (x+X_OFFSET, Y_OFFSET, x+X_OFFSET, Y_MAX+Y_OFFSET);
    }    
    count++;
  }
  for (int y=0; y<=Y_MAX; y+=Y_DIST)           // horizontal lines 
  {
    line (X_OFFSET, y+Y_OFFSET, X_MAX+X_OFFSET, y+Y_OFFSET);
    textFont(fontA, 16);
    text( (Y_MAX-y), 7, y+Y_OFFSET+6);
  }
  textFont(fontA, 32);
  fill(graphColor); 
  text("128-Channel Spectrum Analyser", 215, 40);
  textFont(fontA, 16);
  text("magnitude", 7, 20);  
  text("(8bit-value)", 7, 40);  
  text("--> channel (number i)", X_OFFSET, Y_WINDOW-Y_OFFSET/2);
  text(" frequency   f ( i ) = i * SAMPLE_RATE / FHT_N ", 350, Y_WINDOW-Y_OFFSET/2 );
} 

void serialEvent(Serial p)                      // ISR triggerd by "port.buffer(129);"
{ 
  if ( 255 == port.read() )                     //  1 start-byte               
  {
    inBuffer = int( port.readBytes() );         // 128 data-byte
  }
}

void setup() 
{ 
  size(X_WINDOW, Y_WINDOW);                      // size of window
  noStroke();
  fontGraph = loadFont("ArialUnicodeMS-48.vlw");
  textFont(fontGraph, 12);
  println(Serial.list());                        // show available COM-ports
  port = new Serial(this, Serial.list()[2], 115200);  // choose your COM-port instead of "COM7"
  port.buffer(129);                              // 1 start-byte + 128 data-bytes 
  fontA = loadFont("ArialUnicodeMS-48.vlw");
  textFont(fontA, 16);
}

void draw() 
{ 
  int count=0;

  draw_grid();

  for (int i=0; i<128; i++)
  { 
    fill(graphColor);
    rect(i*X_DIST+X_OFFSET+X_DIST-COL_WIDTH/2, height-BOT_DIST, COL_WIDTH, -inBuffer[i]);
    if ( X_ENUM == count || 0 == count)
    { 
      text(i, (i+1)*X_DIST+X_OFFSET-COL_WIDTH/2, height-BOT_DIST+25);
      count=0;
    }
    count++;
  }
}

I also attached the analyzer that pops up when I run it but no incoming data shown
Please Help!

First of all, if your arduino is blinking after you loaded your code, then you either are blinking it within your program or it did not upload. Question: Does it seem to upload very quickly like in 5 seconds? If it does it failed and you are uploading it the wrong way.

You do not post any errors, your IDE output when you upload, or for that matter your code, thus we cannot help any further.