I have two Arduino unos, and I am using I2C to have them communicate with each other. The A4, A5, and GND of each Arduino is connected to the other. These are my functions:
On the sending Arduino:
void playNote(int pitch, int len, int location){
Serial.println(String(String(location) + ":" + String(pitch) + "," + String(len) + "\n"));
Wire.beginTransmission(location);
Wire.write(pitch);
Wire.write(len);
Wire.endTransmission();
}
On the receiving Arduino:
void receiveEvent(int howMany){
int pitch = Wire.read();
int len = Wire.read();
Serial.println("Pitch: " + String(pitch) + ", Length: " + String(len));
playNote(pitch,len);
}
pitch always sends fine. When I send len as 150, it works and is received as 150. However, when len is sent as 300, it is received as 44. I cannot figure out why this is. Any help is appreciated.