So i v casted a float value by saying
float val;
int myInt = (int)val;
however this integer still appears to be 4 bytes long and i want to transmit it as a 2 byte integer. is there a way to convert a 4 byte int to 2 bytes?
So i v casted a float value by saying
float val;
int myInt = (int)val;
however this integer still appears to be 4 bytes long and i want to transmit it as a 2 byte integer. is there a way to convert a 4 byte int to 2 bytes?
however this integer still appears to be 4 bytes long
It is not. You'll have to explain why you are operating under this incorrect assumption.
Integer on the Arduino is 2 bytes.
however this integer still appears to be 4 bytes long
How do you know it isn't 2?
romarshmallow:
however this integer still appears to be 4 bytes long and i want to transmit it as a 2 byte integer. is there a way to convert a 4 byte int to 2 bytes?
Arduino DUE or what?
The type "int" is platform dependent.
If you want 2-byte integers, use "int16_t" in your variable declaration!
sorry about this post, i tried to delete it earlier but i couldnt. the integer is in fact 2 bytes. I was sending the integer via serial.println so extra bytes were because i was sending the integers as characters.