Monday, May 6, 2013

Simple Arduino Serial Communications Example

I had done a little serial work with the Arduino and my 'Bot but wanted to try another example.   In this case I have a sketch that  has the Arduino being the  receiver of a one way ASCII data stream.   The data stream uses two sync chars followed by two characters that will make up a two char integer. 

A real implementation would probably use character 127 but I am using "%" for illustrative purposes.  A real implementation would also recognize that the second of two chars of data could be a 127 and therefore you could see two sync characters where one of them is really data.

%%GF%%HG%34%%4%%%HH
   
First payload       - GF
Second payload      - HG
Garbage collected   - %34
Third payload       - 4%
Fourth payload      - HH

%%GF %%HG %34 %%4% %%HH

Here is a link to the sample code.

No comments:

Post a Comment