I have searched for answers and tutorials on this but most seem to cover arrays with small integers or using led's etc.
Lets say I have 3 Integer variables to send to another Arduino, so I can assemble the values into an array
int a = 3;
int b = 123;
int c = 205;
char data[4];
data[0] = a;
data[1] = a;
data[2] = c;
This all works fine when the values are under 255. But what happens if the values are changing constantly as it would if it were a reading from a sensor. variable b suddenly changes its value to 360 for example,
how does this bigger value now get stored in the array I declared?
How would I extract that higher value on the 2nd Arduino if I dont know it has changed to a higher than 255 value.
Any tutorial references would be much appreciated.
That is understood. But as I understand it, when the array gets sent on the serial port, it can only send as char?
So the question is how do I correctly format the array and how to extract the data on the other side?
Your original question failed to mention the serial port. You send bytes (8 bit values) to the serial port, and bytes are received on the other end of the serial connection. Bytes can represent ASCII characters or binary data.
You write a program that determines which bytes are sent, and write a program to receive and interpret them correctly on the other end. Several bytes are often used to represent individual values.
Are you in control of the data collected or do you have a definition of what it represents?
if you control the data use a character that will never appear in the data to delimit each data field, and terminate the record with another unused character or a cr-n/l.
then read into a big enough char array to accomodate the record terminating on the end of record
then you can use the strtock() command to get each data element into its own small char array which you can then convert using atoi() ascii to integer function.
if its not possible to control or delimit the record you may need to rely on a known format
XXXXXXNNNXXXXXNNNNNXXXXX where X is a Alphanumeric N integer
so you know to treat the first 6 chars as a string, the next 3 as an integer value followed by a 4 character string and so on..