Pages: [1]   Go Down
Author Topic: Concatenation Operator  (Read 708 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Full Member
***
Karma: 6
Posts: 200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: