stairs

Hello all. I have the following code on my Arduino Uno (1.03). I want to know if I can send x, y coordinate values, such as (4,8), from the serial port to the Arduino (Uno) and have the arduino recognize that it is getting xy coordinates so they can be parsed out.

void serialEvent() { while (Serial.available()) { // get the new byte char inChar = (char)Serial.read(); // add it to the inputString inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do something about it if (inChar == '\n') stringComplete = true; }}

I want to know if I can send x, y coordinate values, such as (4,8), from the serial port to the Arduino (Uno) and have the arduino recognize that it is getting xy coordinates so they can be parsed out.

You can send the coordinates. The Arduino can read and store them, then parse the packet, when it has a complete packet. Knowing that the packet represents coordinates, without any identifying information in the packet is not possible.

Quote

Is there some way to put in a wildcard, such as '*' to be used in a comparison statement with '=='?

What does this mean? You can compare a String (ugh!) to '*'. But, why?

The art of getting good answers lies in asking good questions.

stairs

Basically I want the Arduino to know it is receiving coordinates (some numbers between parentheses separated by a comma) in the structure I laid out in my code above without having to re-write it all (as I have already written quite a bit of code in this structure).

It is possible for ardui o to receive the parenthesis and the two numbers and the comma. But the processor has absolutely no idea what coordinates are or what they look like. If you want them treated as coordinates or to do anything else with them after they are received then you will have to do that in code.

Read along until you get a (. Then read in and save what's next until you get the comma. Then read in and save the next bit to a different variable until you hit the ). Now look at the two pieces you saved. If they are both numbers (made up of digits and within whatever bounds you've set) then you've got a set of coordinates, go ahead and do what you need to do with them. If they're not numbers or if you don't find the comma or the ) then it was either not coordinates or was corrupted so throw it out.