hello all,
we are experimenting with Arduino for the first time using the I2C connection to another microcontroller.
from ;
we learned that;
a)
void setup()
{
// join i2c bus (address optional for master)
Wire.begin();
}
void loop()
{
Wire.beginTransmission(4); // transmit to device #4
Wire.write("x is "); // write five bytes
Wire.write(x); // write one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(500);
}
is okay
and
b)
void setup()
{
Wire.begin(2);
Wire.onRequest(requestEvent);
}
void loop()
{
delay(100);
}
void requestEvent()
{
Wire.write("hello ");
}
is also okay.
but when we try;
b)
void setup()
{
Wire.begin(2);
Wire.onRequest(requestEvent);
}
void loop()
{
delay(100);
}
void requestEvent()
{
Wire.write("x is "); // write five bytes
Wire.write(x); // write one byte
}
it is not okay.
only the last Wire.write() is received on the master-side.
is the above syntax (two times Wire.write() in a RequestEvent) valid ?