#include // Pin definitions and constants const int localLedPin = 2; // Pin for the local LED const int ledOnCommand = 1; // Command to turn on LED on I2C devices // I2C Slave Device Addresses const int firstSlaveAddress = 0x04; const int secondSlaveAddress = 0x05; void setup() { pinMode(localLedPin, OUTPUT); // Set the LED pin as output Wire.begin(); // Start the I2C bus as master Serial.begin(115200); // Start serial communication at 115200 bps } void loop() { controlLocalLed(true); // Turn on the local LED sendI2CCommand(firstSlaveAddress, ledOnCommand); // Send command to the first slave sendI2CCommand(secondSlaveAddress, ledOnCommand); // Send command to the second slave controlLocalLed(false); // Turn off the local LED } // Function to control the state of the local LED void controlLocalLed(bool turnOn) { digitalWrite(localLedPin, turnOn ? HIGH : LOW); delay(1000); // 1 second delay } // Function to send a command to an I2C device sendI2CCommand(int address, int command) { Wire.beginTransmission(address); // Start transmission to the specified address Wire.write(command); // Send the command Wire.endTransmission(); delay(1000); // 1 second delay }