Pages: [1]   Go Down
Author Topic: Multiple byte serial input  (Read 473 times)
0 Members and 1 Guest are viewing this topic.
Pittsburgh
Offline Offline
Newbie
*
Karma: 0
Posts: 20
I built a Segway...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been scrounging the web for a way to send multiple bytes from my PC to my arduino. I need to be able to send a number( number of sensor counts) ranging from 1 to 1,000, or maybe more. I need this data to be usable as if I had said:

volatile int Dists = 65;

on the arduino
(It is volatile because it needs to be used in an interrupt)

Please Help!
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What program will be doing the sending?

Its easiest to convert the numbers to binary and put a 'marker' between numbers.
For between 1 to 1,000 I'd use a short (two bytes) followed by a null (0x00).

That way its easy for the Arduino to use (one bitshift will combine the two bytes back in to a short in the Arduino) and the protocol is simple.
Logged

Pittsburgh
Offline Offline
Newbie
*
Karma: 0
Posts: 20
I built a Segway...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I must be able to send data to it from a serial terminal, so it must be something I can type on a standard keyboard. I know binary pretty well, so I could handle that, but I still don't know how to implement it.
Logged

Pages: [1]   Go Up
Jump to: