#include "Wire.h" // This is I2C library #include "SoftwareSerial.h" // This is used for making rx tx pins using software #define Rx 1 #define Tx 0 SoftwareSerial myserial(Rx, Tx); // declared Rx and Tx Pins void setup() { Wire.begin(); // I2C communication Started myserial.begin(9600); // Serial communiation Started myserial.println("Communication Started"); } void loop() { char d; // Character type declaration to store a character. if (myserial.available() > 0) { d = myserial.read(); // Read serial and store its value in variable d. if (d == '1') { // Now transmit data over the I2C lines according to the cases. Wire.beginTransmission(1); // Communication started with first node\ myserial.println("send "); Wire.write(1); // Value sent over the channel Wire.endTransmission(); // Communication Ended myserial.println("send :- "); myserial.print(d); // Print on Serial Monitor } if (d == '2') { // Same of others. Wire.beginTransmission(1); Wire.write(2); Wire.endTransmission(); myserial.println("send :- "); myserial.print(d); } if (d == '3') { // Same of others. Wire.beginTransmission(2); Wire.write(3); Wire.endTransmission(); myserial.println("send :- "); myserial.print(d); } } delay(10); // Delay to make sure whole CPU is not consumed. }