Go Down

Topic: Concatenation Operator (Read 1 time) previous topic - next topic


How I can connect multiple variables in one variable (something like . in php)? I need that for receiving array trough serial.


Well the basic C language offers arrays to hold multiple variables, and there are various string libraries to help manage character arrays. However once you start inputting or outputting characters to and from the serial port, you have to deal with single byte transfers in a loop to send or receive full multi-character messages. You also have to define and implement a serial protocol so you know when a valid value or message starts and ends, or how many characters make up a complete transaction. Lots of examples around if you search for them.



Well, I have whole data in array when I'm receiving. But I can't check value with 'if' if I don't connect whole array in one variable.


Hey there,
Check out http://arduino.cc/en/Tutorial/StringAdditionOperator, it looks like it has no problem concatenating strings with '+' instead of '.' like in PHP.

Also, since you are probably not used to variable type declaration (since it looks like you've spent some time with PHP) you might have trouble with variable types on the arduino, but just remember that if something seems to add up weird it could be a variable problem.

Go Up