Having problems translating numerical data into Character values on LCD screen.

Ok, so I'm trying to translate frequency value and have it display the musical note that corresponds with it. I built a circuit and programed the Arduino to evaluate incoming sound waves. I finally got that part of it to work. Now, Im trying to translate what the serial monitor displays in in frequency to the note that corresponds with it. For example if the frequency outputs hertz between 185hz && 208hz, I want the LCD screen to output G3. Ive included the code below. Please keep in mind that i KNOW that its not correctly formatted right but I've tried multiple way to do it and I'm just not getting it function right. If someone can help lead me in the right direction It would seriously make my day.. Thanks ahead of time..

/

/clipping indicator variables
boolean clipping = 0;

//data storage variables
byte newData = 0;
byte prevData = 0;
unsigned int time = 0;//keeps time and sends vales to store in timer[] occasionally
int timer[10];//sstorage for timing of events
int slope[10];//storage fro slope of events
unsigned int totalTimer;//used to calculate period
unsigned int period;//storage for period of wave
byte index = 0;//current storage index
float frequency;//storage for frequency calculations
int maxSlope = 0;//used to calculate max slope as trigger point
int newSlope;//storage for incoming slope data

//variables for decided whether you have a match
byte noMatch = 0;//counts how many non-matches you've received to reset variables if it's been too long
byte slopeTol = 3;//slope tolerance- adjust this if you need
int timerTol = 10;//timer tolerance- adjust this if you need


void setup(){
  
  Serial.begin(9600);
  
  pinMode(13,OUTPUT);//led indicator pin
  pinMode(12,OUTPUT);//output pin
  
  cli();//diable interrupts
  
  //set up continuous sampling of analog pin 0 at 38.5kHz
 
  //clear ADCSRA and ADCSRB registers
  ADCSRA = 0;
  ADCSRB = 0;
  
  ADMUX |= (1 << REFS0); //set reference voltage
  ADMUX |= (1 << ADLAR); //left align the ADC value- so we can read highest 8 bits from ADCH register only
  
  ADCSRA |= (1 << ADPS2) | (1 << ADPS0); //set ADC clock with 32 prescaler- 16mHz/32=500kHz
  ADCSRA |= (1 << ADATE); //enabble auto trigger
  ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
  ADCSRA |= (1 << ADEN); //enable ADC
  ADCSRA |= (1 << ADSC); //start ADC measurements
  
  sei();//enable interrupts
}

ISR(ADC_vect) {//when new ADC value ready
  
  PORTB &= B11101111;//set pin 12 low
  prevData = newData;//store previous value
  newData = ADCH;//get value from A0
  if (prevData < 127 && newData >=127){//if increasing and crossing midpoint
    newSlope = newData - prevData;//calculate slope
    if (abs(newSlope-maxSlope)<slopeTol){//if slopes are ==
      //record new data and reset time
      slope[index] = newSlope;
      timer[index] = time;
      time = 0;
      if (index == 0){//new max slope just reset
        PORTB |= B00010000;//set pin 12 high
        noMatch = 0;
        index++;//increment index
      }
      else if (abs(timer[0]-timer[index])<timerTol && abs(slope[0]-newSlope)<slopeTol){//if timer duration and slopes match
        //sum timer values
        totalTimer = 0;
        for (byte i=0;i<index;i++){
          totalTimer+=timer[i];
        }
        period = totalTimer;//set period
        //reset new zero index values to compare with
        timer[0] = timer[index];
        slope[0] = slope[index];
        index = 1;//set index to 1
        PORTB |= B00010000;//set pin 12 high
        noMatch = 0;
      }
      else{//crossing midpoint but not match
        index++;//increment index
        if (index > 9){
          reset();
        }
      }
    }
    else if (newSlope>maxSlope){//if new slope is much larger than max slope
      maxSlope = newSlope;
      time = 0;//reset clock
      noMatch = 0;
      index = 0;//reset index
    }
    else{//slope not steep enough
      noMatch++;//increment no match counter
      if (noMatch>9){
        reset();
      }
    }
  }
    
  if (newData == 0 || newData == 1023){//if clipping
    PORTB |= B00100000;//set pin 13 high- turn on clipping indicator led
    clipping = 1;//currently clipping
  }
  
  time++;//increment timer at rate of 38.5kHz
}

void reset(){//clea out some variables
  index = 0;//reset index
  noMatch = 0;//reset match couner
  maxSlope = 0;//reset slope
}


void checkClipping(){//manage clipping indicator LED
  if (clipping){//if currently clipping
    PORTB &= B11011111;//turn off clipping indicator led
    clipping = 0;
  }
}


void loop(){
  
  checkClipping();
  
  frequency = 38462/float(period);//calculate frequency timer rate/period
  
// UP TO THIS POINT IM GOOD. BELOW  IS WHERE IM HAVING TROUBLE.

    if (frequency > 15  && frequency < 34 );    

     Serial.print(C1);
    {              
        else if (frequency > 35 && frequency < 38 );
    }
        Serial.print(D1);
  {
        else if (frequency > 39 && frequency < 42 ):
        Serial.print(E1)
        else if (frequency > 42 && frequency < 46 );
         Serial.print(F1)
        else if (frequency > 46 && frequency < 52 );
         Serial.print(G1)
        else if (frequency > 52 && frequency < 58 );
        Serial.print(A1)
        else if (frequency > 58 && frequency < 63 );
         Serial.print(B1)
        
        
        else if (frequency > 63 && frequency < 69 );
         Serial.print(C2)
        else if (frequency > 69 && frequency < 78 );
         Serial.print(D2)
        else if (frequency > 78 && frequency < 84 ):
         Serial.print(E2)
        else if (frequency > 84 && frequency < 95 );
         Serial.print(F2)
        else if (frequency > 95 && frequency < 105 );
         Serial.print(G2)
        else if (frequency > 105 && frequency < 116 );
         Serial.print(A2)
        else if (frequency > 116 && frequency < 127 );
         Serial.print(B2)
        
        
        else if (frequency > 127 && frequency < 139);
         Serial.print(C3)
        else if (frequency > 139 && frequency < 155 );
         Serial.print(D3)
        else if (frequency > 155 && frequency < 170 ):
         Serial.print(E3)
        else if (frequency > 170 && frequency < 185 );
         Serial.print(F3)
        else if (frequency > 185 && frequency < 208 );
         Serial.print(G3)
        else if (frequency > 208 && frequency < 233 );
         Serial.print(A3)
        else if (frequency > 233 && frequency < 255 );
         Serial.print(B3)
        
         
        else if (frequency > 255 && frequency < 277 );
         Serial.print(C4)
        else if (frequency > 277 && frequency < 311 );
         Serial.print(D4)
        else if (frequency > 311 && frequency < 240 ):
         Serial.print(E4)
        else if (frequency > 240 && frequency < 370 );
         Serial.print(F4)
        else if (frequency > 370 && frequency < 415 );
         Serial.print(G4)
        else if (frequency > 415 && frequency < 466 );
         Serial.print(A4)
        else if (frequency > 466 && frequency < 515 );
         Serial.print(B4)
        
        
         
        else if (frequency > 515 && frequency < 555 );
         Serial.print(C5)
        else if (frequency > 555 && frequency < 622 );
         Serial.print(D5)
        else if (frequency > 622 && frequency < 645 ):
         Serial.print(E5)
        else if (frequency > 645 && frequency < 740 );
         Serial.print(F5)
        else if (frequency > 740 && frequency < 830 );
         Serial.print(G5)
        else if (frequency > 830 && frequency < 933 );
         Serial.print(A5)
        else if (frequency > 933 && frequency < 1027 );
         Serial.print(B5)
        
         
        else if (frequency > 1027 && frequency < 1109 );
         Serial.print(C6)
        else if (frequency > 1109 && frequency < 1244 );
         Serial.print(D6)
        else if (frequency > 1244 && frequency < 1370 ):
         Serial.print(E6)
        else if (frequency > 1370 && frequency < 1480 );
         Serial.print(F6)
        else if (frequency > 1480 && frequency < 1661 );
         Serial.print(G6)
        else if (frequency > 1661 && frequency < 1864 );
         Serial.print(A6)
        else if (frequency > 1864 && frequency < 2020 );
         Serial.print(B6)
        
         
        else if (frequency > 2020 && frequency < 2217 );
         Serial.print(C7)
        else if (frequency > 2217 && frequency < 2489 );
         Serial.print(D7)
        else if (frequency > 2489 && frequency < 2725 ):
         Serial.print(E7)
        else if (frequency > 2725 && frequency < 2960 );
         Serial.print(F7)
        else if (frequency > 2960 && frequency < 3322 );
         Serial.print(G7)
        else if (frequency > 3322 && frequency < 3729 );
         Serial.print(A7)
        else if (frequency > 3729 && frequency < 4500 );
         Serial.print(B7)
        
        
        
  
  //print results
  Serial.print(frequency);
  
  
  delay(1000);//feel free to remove this if you want
  
  //do other stuff here
}

  //print results
  Serial.print(frequency);
  Serial.println(" hz");
  
  delay(1000); //feel free to remove this if you want
  
 
}[/font][/font]

To clarify why I'm trying to get it to read over the serial port and not defying the lcd display in the code i was going to add this code below. I figured if the serial port display is right this should work as well..

[code]/*
  LiquidCrystal Library - Serial Input
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch displays text sent over the serial port 
 (e.g. from the Serial Monitor) on an attached LCD.
 
 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe 
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.
 
 http://arduino.cc/en/Tutorial/LiquidCrystalSerial
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
    // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}

[/code]

click the MODIFY button in the upper right of the post window.
Highlight all you code.
click the "#" CODE TAGS button on the toolbar above just to the left of the QUOTE button.
click SAVE (at the bottom).
When you post code on the forum, please make a habit of using the code tags "#" button.

What's the question ?

The question is how do i define multiple numerical data ranges as characters? I have a circuit and program that reads input sound wave data and outputs the frequency over the serial port . Thats working just fine. What I'm trying to do is translate the frequencies into the corresponding note and have them displayed over an LCD screen.

For example, if my frequency data is say between 555hz && 622hz I'm looking for the out put on the serial monitor and LCD screen to read "D5". Im trying to incorporate all the main tones between C1 and C6.. Its around 40 different possible outcomes.. Im not sure if i have to put in 40+ if then statements or do something else.. Thanks for checking it out and i fixed forum message above to include the #'s for the code..

I'm not an experienced programmer so I'll take a wild guess and you can take it or leave it.
First, I would have an array that holds all the notes.
Second, I would use only the low value and high value to determine the note. Everything equal to or between in a group is that note. So an array of arrays. with the second array containing two values. I would use a FOR loop that uses the index to cycle through the array of notes. with an IF statement that checks for a match for the low value , then the high value using >= and <= and if no match increment the index of the note array and check the high value. If no match then increment the index of the array that holds the note arrays and check the next note array the same way, all the while incrementing the index for the array of note arrays only after failing a match for both the low value and high value.

What I'm trying to do is translate the frequencies into the corresponding note and have them displayed over an LCD screen.

That's a different task. That probably involves an array of notes that holds two ASCII values, (one for the note , one for the octave).
You probably need another array that holds the index values of the arrays that hold the note/octave and you probably have to
do a similar thing with those with a FOR loop to COMPARE "D5" with the array that holds the indexes for the note/octave array.
There are a finite number of keys on an eight octave piano keyboard so if you list them from lowest note to highest and assign a number to them then you wind up with an array of 88 (0 to 87) values. Those values hold the location of the 88 two-value arrays that contain the ASCII values (like "D" & "5" (D=0x44)(5=0x35) so "D5" array contains (0x44,0x35). When your freq2note function returns "D5" by checking lower limit and upper limit of a note against the sample, the notecounter variable should be incremented each pass through the FOR loop so when you find a match, the notecounter variable contains the index of the note/ASCII array
(0 to 87).

Thats seems a little beyond me at this time. Instead of an array could I just change the note values in the serial print code below to ASCll format? I feel like I might be complicating it more than I'm capable handling with my current experience. Just to give it a shot would the two arrays look something like this,

frecNoteArray[7]=[C D E F G A B];

frecOctaveNum[7]=[1 2 3 4 5 6 7];

so if the frequency is 294 (D4) than the index value would be (1,3) ?
For some reason I think the values start a 0 so two positions over is actually a one, I'm guessing..

/

/ UP TO THIS POINT IM GOOD. BELOW  IS WHERE IM HAVING TROUBLE.

    if (frequency > 15  && frequency < 34 );    

     Serial.print(C1);
    {              
        else if (frequency > 35 && frequency < 38 );
    }
        Serial.print(D1);
  {
        else if (frequency > 39 && frequency < 42 ):
        Serial.print(E1)
        else if (frequency > 42 && frequency < 46 );
         Serial.print(F1)
        else if (frequency > 46 && frequency < 52 );
         Serial.print(G1)
        else if (frequency > 52 && frequency < 58 );
        Serial.print(A1)
        else if (frequency > 58 && frequency < 63 );
         Serial.print(B1)
        
        
        else if (frequency > 63 && frequency < 69 );
         Serial.print(C2)
        else if (frequency > 69 && frequency < 78 );
         Serial.print(D2)
        else if (frequency > 78 && frequency < 84 ):
         Serial.print(E2)
        else if (frequency > 84 && frequency < 95 );
         Serial.print(F2)
        else if (frequency > 95 && frequency < 105 );
         Serial.print(G2)
        else if (frequency > 105 && frequency < 116 );
         Serial.print(A2)
        else if (frequency > 116 && frequency < 127 );
         Serial.print(B2)
        
        
        else if (frequency > 127 && frequency < 139);
         Serial.print(C3)
        else if (frequency > 139 && frequency < 155 );
         Serial.print(D3)
        else if (frequency > 155 && frequency < 170 ):
         Serial.print(E3)
        else if (frequency > 170 && frequency < 185 );
         Serial.print(F3)
        else if (frequency > 185 && frequency < 208 );
         Serial.print(G3)
        else if (frequency > 208 && frequency < 233 );
         Serial.print(A3)
        else if (frequency > 233 && frequency < 255 );
         Serial.print(B3)
        
         
        else if (frequency > 255 && frequency < 277 );
         Serial.print(C4)
        else if (frequency > 277 && frequency < 311 );
         Serial.print(D4)
        else if (frequency > 311 && frequency < 240 ):
         Serial.print(E4)
        else if (frequency > 240 && frequency < 370 );
         Serial.print(F4)
        else if (frequency > 370 && frequency < 415 );
         Serial.print(G4)
        else if (frequency > 415 && frequency < 466 );
         Serial.print(A4)
        else if (frequency > 466 && frequency < 515 );
         Serial.print(B4)
        
        
         
        else if (frequency > 515 && frequency < 555 );
         Serial.print(C5)
        else if (frequency > 555 && frequency < 622 );
         Serial.print(D5)
        else if (frequency > 622 && frequency < 645 ):
         Serial.print(E5)
        else if (frequency > 645 && frequency < 740 );
         Serial.print(F5)
        else if (frequency > 740 && frequency < 830 );
         Serial.print(G5)
        else if (frequency > 830 && frequency < 933 );
         Serial.print(A5)
        else if (frequency > 933 && frequency < 1027 );
         Serial.print(B5)
        
         
        else if (frequency > 1027 && frequency < 1109 );
         Serial.print(C6)
        else if (frequency > 1109 && frequency < 1244 );
         Serial.print(D6)
        else if (frequency > 1244 && frequency < 1370 ):
         Serial.print(E6)
        else if (frequency > 1370 && frequency < 1480 );
         Serial.print(F6)
        else if (frequency > 1480 && frequency < 1661 );
         Serial.print(G6)
        else if (frequency > 1661 && frequency < 1864 );
         Serial.print(A6)
        else if (frequency > 1864 && frequency < 2020 );
         Serial.print(B6)
        
         
        else if (frequency > 2020 && frequency < 2217 );
         Serial.print(C7)
        else if (frequency > 2217 && frequency < 2489 );
         Serial.print(D7)
        else if (frequency > 2489 && frequency < 2725 ):
         Serial.print(E7)
        else if (frequency > 2725 && frequency < 2960 );
         Serial.print(F7)
        else if (frequency > 2960 && frequency < 3322 );
         Serial.print(G7)
        else if (frequency > 3322 && frequency < 3729 );
         Serial.print(A7)
        else if (frequency > 3729 && frequency < 4500 );
         Serial.print(B7)
        
        
        
  
  //print results
  Serial.print(frequency);

And the ASCII ?

I wouldn't do both, unless I had to. I could look up each corresponding value on the ASCII chart an input those in if it would work in this case.

so if the frequency is 294 (D4) than the index value would be (1,3) ?

 frecNoteArray[7]=[C D E F G A B];

frecOctaveNum[7]=[1 2 3 4 5 6 7];

Why don't you substitute the ASCII values for the element in these arrays and send those ?

Thanks for the help... This is the final code I ended up using. Its not sexy, but it works so far..

Thanks again.

.#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


//clipping indicator variables
boolean clipping = 0;

//data storage variables
byte newData = 0;
byte prevData = 0;
unsigned int time = 0;//keeps time and sends vales to store in timer[] occasionally
int timer[10];//sstorage for timing of events
int slope[10];//storage fro slope of events
unsigned int totalTimer;//used to calculate period
unsigned int period;//storage for period of wave
byte index = 0;//current storage index
float frequency;//storage for frequency calculations
int maxSlope = 0;//used to calculate max slope as trigger point
int newSlope;//storage for incoming slope data

//variables for decided whether you have a match
byte noMatch = 0;//counts how many non-matches you've received to reset variables if it's been too long
byte slopeTol = 3;//slope tolerance- adjust this if you need
int timerTol = 10;//timer tolerance- adjust this if you need


void setup(){

  Serial.begin(9600);

  pinMode(13,OUTPUT);//led indicator pin
  pinMode(12,OUTPUT);//output pin

  cli();//diable interrupts

  //set up continuous sampling of analog pin 0 at 38.5kHz

  //clear ADCSRA and ADCSRB registers
  ADCSRA = 0;
  ADCSRB = 0;

  ADMUX |= (1 << REFS0); //set reference voltage
  ADMUX |= (1 << ADLAR); //left align the ADC value- so we can read highest 8 bits from ADCH register only

  ADCSRA |= (1 << ADPS2) | (1 << ADPS0); //set ADC clock with 32 prescaler- 16mHz/32=500kHz
  ADCSRA |= (1 << ADATE); //enabble auto trigger
  ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
  ADCSRA |= (1 << ADEN); //enable ADC
  ADCSRA |= (1 << ADSC); //start ADC measurements

  sei();//enable interrupts
}

ISR(ADC_vect) {//when new ADC value ready

  //PORTB &= B11101111;//set pin 12 low
  prevData = newData;//store previous value
  newData = ADCH;//get value from A0
  if (prevData < 127 && newData >=127){//if increasing and crossing midpoint
    newSlope = newData - prevData;//calculate slope
    if (abs(newSlope-maxSlope)<slopeTol){//if slopes are ==
      //record new data and reset time
      slope[index] = newSlope;
      timer[index] = time;
      time = 0;
      if (index == 0){//new max slope just reset
        PORTB |= B00010000;//set pin 12 high
        noMatch = 0;
        index++;//increment index
      }
      else if (abs(timer[0]-timer[index])<timerTol && abs(slope[0]-newSlope)<slopeTol){//if timer duration and slopes match
        //sum timer values
        totalTimer = 0;
        for (byte i=0;i<index;i++){
          totalTimer+=timer[i];
        }
        period = totalTimer;//set period
        //reset new zero index values to compare with
        timer[0] = timer[index];
        slope[0] = slope[index];
        index = 1;//set index to 1
        PORTB |= B00010000;//set pin 12 high
        noMatch = 0;
      }
      else{//crossing midpoint but not match
        index++;//increment index
        if (index > 9){
          reset();
        }
      }
    }
    else if (newSlope>maxSlope){//if new slope is much larger than max slope
      maxSlope = newSlope;
      time = 0;//reset clock
      noMatch = 0;
      index = 0;//reset index
    }
    else{//slope not steep enough
      noMatch++;//increment no match counter
      if (noMatch>9){
        reset();
      }
    }
  }

  if (newData == 0 || newData == 1023){//if clipping
    PORTB |= B00100000;//set pin 13 high- turn on clipping indicator led
    clipping = 1;//currently clipping
  }

  time++;//increment timer at rate of 38.5kHz
}

void reset(){//clea out some variables
  index = 0;//reset index
  noMatch = 0;//reset match couner
  maxSlope = 0;//reset slope
}


void checkClipping(){//manage clipping indicator LED
  if (clipping){//if currently clipping
    PORTB &= B11011111;//turn off clipping indicator led
    clipping = 0;
  }
}


void loop(){

  checkClipping();

  frequency = 38462/float(period);//calculate frequency timer rate/period


    // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  lcd.setCursor(0, 1);
  // Print a message to the LCD.


  if (frequency > 15  && frequency < 34 )

  {
    lcd.print('C1');
  }                
  else if (frequency > 35 && frequency < 38 )
  {  
    lcd.print('D1');
  }
  else if (frequency > 39 && frequency < 42 )
  {    
    lcd.print('E1');
  } 
  else if (frequency > 42 && frequency < 46 )
  {
    lcd.print('F1');
  }

  else if (frequency > 46 && frequency < 52 )
  {
    lcd.print("G1");
  }
  else if (frequency > 52 && frequency < 58 )
  {
    lcd.print("A1");
  }
  else if (frequency > 58 && frequency < 63 )
  {
    lcd.print("B1");
  }

  else if (frequency > 63 && frequency < 69 )
  {
    lcd.print("C2");
  }
  else if (frequency > 69 && frequency < 78 )
  {
    lcd.print("D2");
  }
  else if (frequency > 78 && frequency < 84 )
  {
    lcd.print("E2");
  }
  else if (frequency > 84 && frequency < 95 )
  {
    lcd.print("F2");
  }
  else if (frequency > 95 && frequency < 105 )
  {
    lcd.print("G2");
  }
  else if (frequency > 105 && frequency < 116 )
  {
    lcd.print("A2");
  }
  else if (frequency > 116 && frequency < 127 )
  {
    lcd.print("B2");
  }

  else if (frequency > 127 && frequency < 139)
  {
    lcd.print("C3");
  }
  else if (frequency > 139 && frequency < 155 )
  {
    lcd.print("D3");
  }
  else if (frequency > 155 && frequency < 170 )
  {
    lcd.print("E3");
  }
  else if (frequency > 170 && frequency < 185 )
  {
    lcd.print("F3");
  }
  else if (frequency > 185 && frequency < 208 )
  {
    lcd.print("G3");
  }
  else if (frequency > 208 && frequency < 233 )
  {
    lcd.print("A3");
  }

  else if (frequency > 233 && frequency < 255 )
  {
    lcd.print("B3");
  }

  else if (frequency > 255 && frequency < 277 )
  {
    lcd.print("C4");
  }
  else if (frequency > 277 && frequency < 311 )
  {
    lcd.print("D4");
  }
  else if (frequency > 311 && frequency < 240 )
  {
    lcd.print("E4");
  }
  else if (frequency > 240 && frequency < 370 )
  {
    lcd.print("F4");
  }
  else if (frequency > 370 && frequency < 415 )
  {
    lcd.print("G4");
  }
  else if (frequency > 415 && frequency < 466 )
  {
    lcd.print("A4");
  }
  else if (frequency > 466 && frequency < 515 )
  {
    lcd.print("B4");
  }
  else if (frequency > 515 && frequency < 555 )
  {
    lcd.print("C5");
  }
  else if (frequency > 555 && frequency < 600 )
  {
    lcd.print("D5");
  }
  else if (frequency > 600 && frequency < 670 )
  {
    lcd.print("E5");
  }
  else if (frequency > 670 && frequency < 740 )
  {
    lcd.print("F5");
  }
  else if (frequency > 740 && frequency < 830 )
  {
    lcd.print("G5");
  }
  else if (frequency > 830 && frequency < 933 )
  {
    lcd.print("A5");
  }
  else if (frequency > 933 && frequency < 1027 )
  {
    lcd.print("B5");
  }

  else if (frequency > 1027 && frequency < 1109 )
  {
    lcd.print("C6");
  }
  else if (frequency > 1109 && frequency < 1244 )
  {
    lcd.print("D6");
  }
  else if (frequency > 1244 && frequency < 1370 )
  {
    lcd.print("E6");
  }
  else if (frequency > 1370 && frequency < 1480 )
  {
    lcd.print("F6");
  }
  else if (frequency > 1480 && frequency < 1661 )
  {
    lcd.print("G6");
  }
  else if (frequency > 1661 && frequency < 1864 )
  {
    lcd.print("A6");
  }
  else if (frequency > 1864 && frequency < 2020 )
  {
    lcd.print("B6");
  }

  else if (frequency > 2020 && frequency < 2217 )
  {
    lcd.print("C7");
  }
  else if (frequency > 2217 && frequency < 2489 )
  {
    lcd.print("D7");
  }
  else if (frequency > 2489 && frequency < 2725 )
  {

    lcd.print("E7");
  }
  else if (frequency > 2725 && frequency < 2960 )
  {
    lcd.print("F7");
  }
  else if (frequency > 2960 && frequency < 3322 )
  {
    lcd.print("G7");
  }
  else if (frequency > 3322 && frequency < 3729 )
  {
    lcd.print("A7");
  }
  else if  (frequency > 3729 && frequency < 4500 )
  {
    lcd.print("B7");
    }
  }

  //print results
  //Serial.print(frequency);
  //Serial.println(" hz");

 //delay(1000);//