#include <Wire.h>
const int ledPin = D1; // Pin of the LED
void setup() {
pinMode(ledPin, OUTPUT);
Wire.begin(0x09); // Slave address
Wire.onReceive(receiveEvent);
Serial.begin(9600);
}
void loop() {
// Nothing to do here
}
void receiveEvent(int howMany) {
while (Wire.available()) {
char c = Wire.read();
if (c == 'L') { // Command to turn on the LED
digitalWrite(ledPin, HIGH);
}
}
}