if (Wire.available() >= 2) lsb; Serial.println(data);
#include <Wire.h> int x = 42; void setup() Wire.begin(0x08); // Join bus as slave at address 0x08 Wire.onRequest(sendData); // Call function when master requests
void sendData() Wire.write(x);
void loop() // Send register address to read (e.g., 0x00) Wire.beginTransmission(0x68); // MPU6050 address Wire.write(0x00); Wire.endTransmission(false); // Send restart
#include <Wire.h> void setup() Serial.begin(9600); Wire.begin();
Slave (Arduino #1):
void loop()