Arduino Mega Serial.read() and Serial.parseint() Issue

The below example code for Serial.write does not give expected results.

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);
}
}

If the serial monitor is used to send a value like "100" the ASCII is printed back to the serial monitor.

If the .parseint() is used instead of .read() then the correct integer values is reported but then and addition "0" is printed back out.

For example if you sent "100" by the serial monitor then you get the following printed back out:

"I received: 100
I received: 0"

Any idea why the serial .read() and .parseint() are not giving he expected results?

Any idea why the serial .read() and .parseint() are not giving he expected results?

Perhaps because your expectations are wrong.

On the Serial Monitor, what line ending do you have selected?

Yep, I figured that is where the 0 was coming from in the serial monitor.

This all started with trying to run the "Dimmer" example int eh communications examples section.

With the parseInt() I can get the serial monitor and get the expected result from the LED output.

But using the Processing code does not work correctly.

Just wondering why.

Thanks

But using the Processing code does not work correctly.

Just wondering why.

Just wondering what Processing code you are talking about. Working with which Arduino code?

"Dimmer" example in the communications examples section.