Serial Monitor incoming and outgoing data difference

Hello Guys,

Is there a chance to distinguish between incoming data (data that comes from the arduino and is printed in the serial window) and outgoing data (stuff that I write into the serial monitor). I get a bunch of data from my arduino to my serial monitor, but I would like to set an if statement, which just runs when I write "Z" into the serial monitor for example.

Thanks!

What you are asking doesn't make a lot of sense. EVERYTHING that you see in the output window of the Serial Monitor came from the Arduino.

PaulS:
What you are asking doesn't make a lot of sense. EVERYTHING that you see in the output window of the Serial Monitor came from the Arduino.

But what if I send it with my computer to the serial port.

But what if I send it with my computer to the serial port.

You can't have two applications talking the Arduino at once. So, you can NOT have some other application on the computer sending data to the serial port.

But what if I send it with my computer to the serial port.

Then those data go to the Arduino. They are completely separate from the data sent by the Arduino to the computer.

The tutorial Serial Input Basics should help.

Perhaps you left and echo function in the program? Post your code.

if(Serial.available()>0 && Serial.read() == 'Z'){
    Serial.println("Offset Calculating");
    buttonState1 = 1;
    buttonState2 = 1;      
      }

This is part of the code. When I write Z, it should set those two flags to calculate an offset afterwards. The problem is, that the arduino constantly sends values to the port, that I need, so Serial.available() is always > than 0... I mean, with the second statement Serial.read() == 'Z' it kind of works now, but it is more random...

Add some parenthesis to that if statement to make sure is what you think it is.

You think it is

( (Serial.available()>0) && (Serial.read() == 'Z')

Is [ Serial.available()>0

AND

Serial.read() == 'Z' ]

true?

but it might be

( ((Serial.available()>0) && Serial.read()) == 'Z')

Is [ Serial.available()>0

AND

Serial.read() ]

equal to 'Z'

Big difference.

When your if statement does not evaluate as you expect, then it is probably not written (or read by the compiler) as you think.

Where is the rest of the program with the other Serial.print statements? Snippets of code get snippets of answers (or snippy answers).

Maitschi95:
This is part of the code.

Post a complete program.

...R

The problem is, that the arduino constantly sends values to the port, that I need, so Serial.available() is always > than 0...

That is horsecrap. What the Arduino sends OUT the serial port has NO bearing on what is IN the incoming buffer. It is that buffer that available() reports on.