// Include Arduino Wire library for I2C #include // Define Child I2C Address #define CHILD_ADDR 9 int distance; int buzzer = 10; void setup() { // Initialize I2C communications as Child Wire.begin(CHILD_ADDR); // Function to run when data received from father Wire.onReceive(receiveEvent); Serial.begin(9600); } void receiveEvent(int numBytes) { distance = Wire.read(); } void loop() { Serial.println(distance); // tone(buzzer,distance); // delay(500); noTone(buzzer); delay(500); }