Hello everyone.
I think questions about i2C was ask several times. I've looking for a solution here and on google but I don't find it or there is something I miss understand.
Classical situation :
I get 2 Arduino
Linked together on i2C
I need to send integer data from slave to master with RequestFrom method.
code on MASTER :
void SLAVE_GET( int type, int way ){
SLAVE_SET(type*10+way); // sub function to set slave on desired data
delay(100);
Wire.requestFrom(8, 2); // request 2 bytes
Serial.println(Wire.available()); // show how much bytes availables
while( Wire.available() )
{
Serial.println(Wire.read()); // show every bytes
}
}
code on SLAVE
void SEND(){
Serial.println( "i2C === SEND" ); // show that Master request something
int val = 720; // just a test value
Serial.println( val ); // show what are going to be send
Wire.write( val ); // send val.
}
results :
instead of 720, master show 208 and 255.
720 = 0000001011010000
208 = 0000000011010000
255 = 0000000011111111
that meaning master only get ONE of the 2 bytes and the second (or the first, what is the order ?) the second is "put" on 255 value
I don't understand why.

