#include void setup() { Wire.begin(1); // Begin using Wire in slave mode, where it will respond at "1" when other I2C masters chips initiate communication. Wire.onReceive(receiveEvent); // Causes "receiveEvent" to be called when a master device sends data. This only works in slave mode. Serial.begin(9600); //start serial communication pinMode(13,OUTPUT); //LED pin on arduino } byte x = 0; void loop () { delay(100); } //function that executes whenver data is received from master //this function is registered as an event void receiveEvent(int howMany){ //howMany contains the amount of bytes of the received data while(Wire.available()){ char c = Wire.read(); Serial.println(c); if (c == 's') {digitalWrite (13,HIGH);} //Turn on LED else if (c == 'x') {digitalWrite (13,LOW);} //Turn off LED } }