#include <Wire.h>
#include <Arduino.h>

uint8_t count = 0;

void setup() {
  Wire.begin(); // Master
  Serial.begin(9600);
}

void loop() {

  // Send count to slave
  Wire.beginTransmission(0x42);
  Wire.write(count);
  Wire.endTransmission();

  Serial.print("Sent: ");
  Serial.println(count);

  // Request response from slave
  Wire.requestFrom(0x42, 1);
  if (Wire.available()) {
    uint8_t response = Wire.read();
    Serial.print("Received: ");
    Serial.println(response);
  }

  count++;
}
