Sending integer values through serial


hi guys,

i trying figure out best way send integer value 1 due board via serial (tx/rx). receive value sensor (compass) integer , want send straight board no 2.

but not getting same value board 1 board no2. have searched online , have come across/tried soooo many different approach confusing hell out of me.

all need is, if send 45 should receive 45. 

bit lost, or i'm missing something

please help!!

board 1 sender:

code: [select]


int compassvalue;

void setup() {
serial1.begin(115200);

compassvale = 359;

}

void loop() {


serial1.write(compassvalue);  // sent binary???
delay(200);


}






board 2 receiver:



code: [select]




void setup() {
serial1.begin(115200);

}

void loop() {
   if (serial1.available())
  {

      serial.print(serial1.read());  // (debug) want send data serial read integer sd card/
delay(200);


}







have @ examples in serial input basics - simple reliable ways receive data. system in 3rd example reliable.

it easier make sending code match receiving code rather vice versa.

it easier debug programs if data sent human readable characters rather binary data. suggest use binary data if required throughput can't achieved other way.

...r


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Sending integer values through serial


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'