yep sorry. here it goes: for the Due (master)
#include <Wire.h>
int old, now;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(115200);
Serial.println("I2C test starting...");
old=millis();now=millis();
}
void loop() {
if(Serial.available())
{
Wire.beginTransmission(0x02);
Wire.write(Serial.read());
Wire.endTransmission();
}
old=now;
Wire.requestFrom(0x02,1);
//delay(1);
while(Wire.available())
{
char c=Wire.read();
if(c>31)Serial.println(c);
}
// put your main code here, to run repeatedly:
}
and for the Uno:
#include <Wire.h>
char buffer[256];
byte serialpos=0, wirepos=0;
void setup() {
// put your setup code here, to run once:
Wire.begin(0x02);
Serial.begin(115200);
Serial.println("I2C test Starting...");
Wire.onRequest(handler);
Wire.onReceive(receiver);
}
void loop() { // put your main code here, to run repeatedly:
}
void handler()
{
if(Serial.available())
{
char c=Serial.read();
Wire.write(c);
}
}
void receiver(int num)
{
while(Wire.available())
{
char c=Wire.read();
Serial.println(c);
}
}
Hope this helps