Serial I/O problem

Hey,

I´m trying to work out how to get Processing talk to the arduino and the arduino to Processing, but i even couldnt do the first steps. Even with the serial monitor for the arduino and a basic echo script doesnt give me just the echo.
This sctipt from the arduino serial.read reference

int incomingByte = 0; // for incoming serial data

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {

// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}

I send a 1 over the serial i get back 49 and then new line a 10. I dont wonder about the numbers, I know its the ASCII values, but i dont get why i always get two echos. Even tried different serial speed but then i dont even get anything readable back.
I tried around and tried to google it but it didnt helped, so im thankfull for any advice

I send a 1 over the serial i get back 49 and then new line a 10. I dont wonder about the numbers, I know its the ASCII values, but i dont get why i always get two echos.

First, you are NOT sending a 1. You are sending a ‘1’.

Second, you didn’t mention what line ending mode (lower, right corner of the Serial Monitor application) you are using. The fact that you get a second value tells me that it is not None.

If you want Processing on a computer to talk to the arduino over the usb/serial connection, then you can't use serial monitor at the same time.

Processing has plenty of examples of it working, I had no trouble getting it to work, and I am a magnet for trouble.

hmschlesi:
I know its the ASCII values, but i dont get why i always get two echos.

The new line (10) is because you have the lower-right hand corner of the serial monitor set to "Newline". Which means each time you hit send, whatever is in the text box is sent plus that character (or whatever the drop down is set to).

If you don't want the ASCII values, then don't use the "DEC" modifier in your Serial.print() statement.

Very simple serial monitor echo code you can try.

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

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="";
  } 
}