Start by reading the potentiometer. Add a Wire request service function and that makes the Slave:
#include <Wire.h>
const uint8_t controllerAddress = 8;
const int controllerPin = A0;
volatile int controllerValue = 0;
void setup() {
Wire.begin(controllerAddress);
Wire.onRequest(requestEvent);
}
void loop() {
int value = analogRead(controllerPin);
noInterrupts();
controllerValue = value;
interrupts();
}
void requestEvent() {
Wire.write((const uint8_t*) &controllerValue, sizeof(controllerValue));
}
This is minor update of the Arduino Wire Master Reader tutorial. The sketch for the Master is left as an exercise.
Cheers!