#include #include constexpr uint8_t ledPin = D2; // Pin for the LED constexpr uint8_t i2cAddress = 0x04; // I2C address of this device volatile int receivedByte = 0; // Stores the received byte void setup() { pinMode(ledPin, OUTPUT); // Configure the LED pin as output Wire.begin(i2cAddress); // Set this device's I2C address Wire.onReceive(onI2CReceive); // Set the I2C receive function Serial.begin(115200); // Start serial communication at 115200 bps } void loop() { delay(200); // Passive wait for I2C commands } void onI2CReceive(int byteCount) { while (Wire.available() > 0) { receivedByte = Wire.read(); // Read the received byte if (receivedByte == 1) { digitalWrite(ledPin, HIGH); // Turn on the LED delay(1000); // Keep the LED on for 1 second digitalWrite(ledPin, LOW); // Turn off the LED } } }