#include // includes the I2C library //String readString; // this variable will be used to store on or off commands given in the serial monitor. byte I2C_OnOff; // a byte variable with which we will send information to the slave via I2C void setup() { Wire.begin(); // start the I2C communication Serial.begin(9600); // start the Serial communication Serial.println("Type On to turn on the LED and Off to shut it down!"); // write on the monitor for note for a user }a void loop() { while (Serial.available()) // check if the user has inserted anything in the serial monitor and read it { delay(2); char c = Serial.read(); // store this information through char c variable letter by letter readString += c; // and move these characters inside a readString string } if (readString == "BlueOn" or readString == "BLUEON" or readString == "blueon") // an if statement which will determine the value of a I2C_OnOff variable depending on the users input { I2C_OnOff = 1; // If the user inserts "BlueOn", "BLUEON" or "blueon" the I2C_OnOff variable will store number 1 } else if (readString == "BlueOff" or readString == "BLUEOFF" or readString == "blueoff") { I2C_OnOff = 0; // If the user inserts "BlueOff", "BLUEOFF" or "blueoff" the I2C_OnOff variable will store 0. } if (readString.length() > 0) { Serial.println(readString); // displaying the users input on the Serial Monitor readString = ""; // If the readString string has any value display this value and empty the string } Wire.beginTransmission(1); // open the transmission with the student that has an address 1 Wire.write(I2C_OnOff); // send it a byte I2C_OnOff value Wire.endTransmission(); // end the transmission. }