I am currently developing a project in which two microcontrollers communicate with eachother over UART.
So far, I had no problems with sending data (bytes) between the microcontrollers.
But now, I need to send 16bit(int) and 32bit(unsigned long) variables over UART.
How can I split up bigger integer types into two/four bytes to send them over UART and then join them together again?
I would need something like this:
int var1; unsigned long var2; byte arr1; byte arr2; //Somehow convert this MyUARTProtocol.transmit(arr1, 2); MyUARTProtocol.transmit(arr2, 4);
And on the other microcontroller:
byte arr1; byte arr2; //Somehow convert this int var1; unsigned long var2;