I am trying to send data from one arduino to another over ethernet using udp protocol. In arduino writing data over udp is like this
where buffer is an array to send as a series of bytes and size is the size of the array.
Now, i am reading a sensor value from a0 pin of the arduino it will be stored either in int or float type variable. As mentioned earlier udp only sends byte type array. so all i want to do is convert the value stored in the variable to the byte type array. my variable will be.
pinMode(A0,INPUT); int data; byte data_array[Size];
and in loop
now i have convert this value in data_array;
Please provide the suggestion with proper explanation. Thank you