Writing an Array with Serial3 on mega 2560

Hey guys!

I'm just getting started with transmitting data serial between arduinos. I already used the handshake principle.

Now I want to send an Array with 52 integers to a second arduino. How can I send and then get the data into an Array on the second arduino again?

(I use Serial3, two arduinos mega 2560)

Thanks so much bye

What have you tried?

There’s nothing special you need to do other than agree (with yourself) on a protocol remembering that typically you’ll be sending 8 bit bytes.

I find it easier to handle the incoming data if the high byte is sent first then you can receive thus:

int incoming = high_order_byte
incoming <<= 8
incoming &= low_order_byte

increment your index and stuff it on your array.

integers, or int types specifically?

Best to use uint16_t on the receiving end, uint8_t on the send. That way the data gets handled as two packets of 8 bits without concern for what the contents represent.

On the transmit side, make byteL = your_integer_value & 255 or 0B00000000 and then byteH becomes your_integer_value >> 8.

DKWatson: your_integer_value & 255 or 0B00000000

Whaaa?

0B11111111

Better? Should have been looking at the keyboard, or the screen. Sorry.

Still waiting for a response to reply #1...

Me too....