#include #define LedPin 13 void setup() { Wire.begin(4); // join i2c bus with address 4 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output pinMode(LedPin, OUTPUT); // initialize LEDpin as an output } void loop() { digitalWrite(LedPin, HIGH); // turn the LED on by making the voltage HIGH delay(1000); // wait for a second digitalWrite(LedPin, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } void receiveEvent(int howMany) // function that is registered as an event whenever data is received from master { while(1 < Wire.available()) // loop through all but the last { char c = Wire.read(); // receive byte as a character Serial.print(c); // print the character } int x = Wire.read(); // receive byte as an integer Serial.println(x); // print the integer }