Serial read producing random value

I have played with this for a few hours and I am lost.

Desired result: I type a number in the comport, hit enter, the comport replies the number back to me.

Simple code:

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  while (Serial.available() > 0)
  {
  Serial.println(Serial.available());
  Serial.println(Serial.read());
  Serial.print("I received: \n");
  delay(1000);}
}

Output (looks random to me):
63
51
I received:
63
51
I received:
63
154
I received:
63
154
I received:
63
211
I received:
63
211
I received:
63
243
I received:

Notes: I am not typing anything into the comport. Serial.available is always > 0 with a value of 63 and serial.read seems random.

Tried: I went to using another board for the serial communication. (IE: Hooked a second board into pc and hooked second board rx and tx to the board in question(board 1) ) The data looks the same regardless if rx is connected.

Serial.println(analog value) works flawlessly...So im not sure exactly what the problem is stemming from.

Any info would be greatly appreciated.

Setup:
Programing environment: arduino IDE
Programmer: USBtinyISP
Board running at: 16MHz
Board: Atmega2560

[quote]Desired result: I type a number in the comport, hit enter, the comport replies the number back to me.[/quote]
So, that's exactly what your code is doing. Sort of.

[code]  Serial.println(Serial.available());

Anonymous output has always irritated me. This is no exception.

  Serial.println(Serial.read());

Serial.read() returns an int, not a char. Serial.print(), given an int, converts it to a string. Given a char, it does something completely different. If you expect a char output, do not give the function an int.

  Serial.print("I received: \n");

Why would you print this AFTER you printed what you got?[/code]

Well my issue was persisting due to leaving the RX floating

I can't help but think that the 63 you keep seeing has something to do with the Serial buffer size, which is 64. Try modifying the code to use Serial.ReadBytesUntil(), passing in a newline character ('\n'), and a buffer that you have allocated for 70 chars (e.g., char buffer[70]) and then print out what you get.

JTC_RWL:

void setup()

{
  Serial.begin(9600);
}

void loop()
{
  while (Serial.available() > 0)
  {
  Serial.println(Serial.available());
  Serial.println(Serial.read());
  Serial.print("I received: \n");
  delay(1000);}
}

Serial.println(Serial.available()) only printss the number of bytes that have been received in the serial buffer.

Serial.println(Serial.read()); prints one byte, and what it is will be dependent on what character has been received.

Serial.print("I received: \n"); only prints "I received: " , (without the quotes), folowwed by a newline character.

Then it goes around the loop again, and keeps doing that until it has exhausted all the bytes in the serial buffer.

It would be wortwhile reading Nick Gammon's tutorial on Process incoming serial data without blocking at Gammon Forum : Electronics : Microprocessors : How to process incoming serial data without blocking

Very simple serial code.

// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

/*Very simple serial test code. Copy and paste into the IDE code 
area. Upload via clicking the IDE upload arrow. When upload 
finished, open the serial monitor by clicking the serial monitor 
icon in the upper right of the IDE. Ensure 9600 baud rate is 
selected in the serial monitor. Type something in the serial 
monitor text box and send. What was typed in the text box should 
be sent back to the serial monitor display. */

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial test 0021"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(2);  //delay to allow byte to arrive in input buffer
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);

    readString="";
  } 
}