#include const int LED_1_PIN = 5; const int LED_2_PIN = 6; const int LED_3_PIN = 7; void setup() { pinMode(LED_1_PIN, OUTPUT); pinMode(LED_2_PIN, OUTPUT); pinMode(LED_3_PIN, OUTPUT); Wire.begin(0x09); // Join I2C bus with address #9 Wire.onReceive(receiveEvent); // Register event } void loop() { // Nothing needed in the loop } void receiveEvent(int howMany) { if (howMany > 0) { byte ledStates = Wire.read(); digitalWrite(LED_1_PIN, ledStates & 0x01 ? HIGH : LOW); digitalWrite(LED_2_PIN, ledStates & 0x02 ? HIGH : LOW); digitalWrite(LED_3_PIN, ledStates & 0x04 ? HIGH : LOW); } }