buycris:
It manges to send the letters 'a', 'b', 'c' ok which must be stored as more then a byte?
Those character are all stored in one byte.
These two declarations are functionally the same:
char c = 'a';
char c= 99;
Would I have to define the variable I want to send before as a float or int say:
ie: int val = 300;
Wire.write(val):Is it default to a byte? Would be grateful if you could explain how this is working.
300 represented in binary is 1 0010 1100b. The problem is that Wire.write only can send on 8 bits at a time; The value 300 requires 9 bits, so the function has to choose either the high order or low order to send when you pass it an int. Because int is commonly used when the high order portion is not needed (all 0s), they chose the low order. That means that 0010 1100b in sent which, not surprisingly, is 44.
In order to send a value that needs more than 8 bits, you need to split it up. The code above will allow you to send the high byte (0000 0001b) followed by the low byte (0010 1100b). So when you are reading the bytes on the slave, you will need to know at what point you are receiving a two byte value. From there it is pretty easy to convert back: highByte * 16 * 16 + lowByte. (1 * 16 * 16 + 44 = 300).