Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I would like to send information between my Arduino and my computer. Is there a way to send multiple variables from one Arduino? If so, how would I go about separating the variables?

share|improve this question
    
This may help: electronics.stackexchange.com/a/79321/8627 –  jippie Jul 6 '14 at 6:48

2 Answers 2

up vote 1 down vote accepted

You have three options for what you want to achieve (if I understand it right):

  • Have a fixed length for each variable: If I know each number is going to be two digits, I can send "1234" and the other side can figure out the numbers are "12" and "34".
  • Have a delimiter character: Have a character that signals a new variable. For example: "213|1234" would translate into "213" and "1234". You could even use the newline character to signal a new line (with Serial.println();).
  • Do some sort of validation to separate the data: If sending a favorite number and favorite color, I can send "12RED345BLUE" and the other side it can find that it's "12" (both numbers), then "RED" (all letters), then "345" (three numbers), and finally "BLUE" (again, all letters).
share|improve this answer
    
♦ can we do this like this as well? 'LI5' or something like this? 'LA4|LI5' or something like Serial.println('LA4|LI5'); Serial.println('LT2|LP3|LM5|LR4|LI6'); //close reverse will open thanks in advanced. –  Frank's Desig'Nature 2 days ago
    
@Frank'sDesig'Nature there's no reason you can't do that; you would just have to have the appropriate processing on the other side to handle that –  Annonomus Penguin yesterday

im not being allow to comment or edit so this is the only way for me to input my next comment "i really hate how this website works"

Ok so now if i was to flood the serial with something like this:

gfhvfglfngvern98t34u05u305v4up0653utvp53t4t56526vgf5gvsd4gv6h4d65h4d63hbd4hb354g35gb435vb4zf35gdf35gb4d3v5h4vg3v5hb4fg6z24gv6dfgv4fd65vg2652f6g5hb74ki6k57n6v54sh64yul6oh4;g6fjd4g6wr5cg4yrdb68oin7n6ubj84g6jnujg4hm;l62g4kn6gfj42mjh6l54g6k5gf4dbhv16d5sg41tb6uh541jh1j34nfj35ffff4n4j2h3n14b5jgn352ghj3kj18hbuni5dj6tui5dty32hf3h1bgh3gfhvfglfngvern98t34u05u305v4@p0653utvp53t4t56526vgf5gvsd4gv6h4d65h4d63hbd4hb354g35gb435vb4zf35gdf35gb4d3v5h4vg3v5hb4fg6z24gv6dfgv4fd65vg2652f6g5hb74ki6k57n6v54sh64yul6oh4;g6fjd4g6wr5cg4yrdb68oin7n6ubj84g6jnujg4hm;l62g4kn6gfj42mjh6l54g6k5gf4dbhv16d5sg41tb6uh541jh1j34nfj35ffff4n4j2h3n14b5jgn352ghj3kj18hbuni5dj6tui5dty32hf3h1bgh3

ok so lets say all this load of chars are actual values that i have assign to breaks on my switch statements right, now in the middle of all this clutter there's a '@' and lets say tha @ is for a specific mcu running a sketch that will do this block if this @ its seen in serial "there should be no problrm with that right? every single character number or symbol is send via serial for a specific function in a specific mcu. im guessing there should be no issues with this clutter right Annonomus Penguin ?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.