IC2 communication

Hello

I am working on 4 arduino devices in which I want to communicate between 3 slaves writer and 1 master reader.

the problem is how can I make the master reader take the data from each slave and distinguish them into different variable???

this code for the master reader, while the three slaves sending a byte of these variable (x, y, z)

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5 , 4, 3 ,2);
#include <Wire.h>
byte x = 0;
byte y = 0;
byte z = 0;
int street1= 0;
int street2= 0;
int street3= 0;

void setup() {
Serial.begin(9600);
lcd.begin(20,4);
lcd.setCursor(5,1);
lcd.print("Hello");
delay(2000);
lcd.clear();
Wire.begin();
}

void loop() {
   Wire.requestFrom(..............)
   .............
   .................
   ..............
   ............

}

:confused:

Is that a school project where you are being asked to fill in the blank?

Put some code with one reader and one writer together and then ask yourself how to deal with more than one

Sorry, I did these blanks because I've not known how to do it.

These what I have done with one reader and one writer and they work properly.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5 , 4, 3 ,2);
#include <Wire.h>
byte x = 0;
byte y = 0;
byte z = 0;
int street1= 0;
int street2= 0;
int street3= 0;

void setup() {
Serial.begin(9600);
lcd.begin(20,4);
lcd.setCursor(5,1);
lcd.print("Hello");
delay(2000);
lcd.clear();
Wire.begin();
}

void loop() {
   Wire.requestFrom(8, 1); //request 1 bytes form slave #8

   while (Wire.available()) {
    x = Wire.read();
   }
   street1= x;

delay(500);
lcd.setCursor(0,0);
lcd.print("street1 = ");
lcd.print(street1);

}

So, when you request data from a different slave, store the response in a different variable.

You mean I should use as it is following? :

   Wire.requestFrom(8, 1); //request 1 byte form slave #8

   while (Wire.available()) {
    x = Wire.read();
   }
   Wire.requestFrom(9, 1); //request 1 byte form slave #9

    while (Wire.available()) {
      y = Wire.read();
    }

   Wire.requestFrom(10, 1); //request 1 byte form slave #10

    while (Wire.available()) {
      z = Wire.read();
   }
   street1= x;
   street2= y;
   street3= z;

You mean I should use as it is following? :

I don't see the need to have x, y, and z. You can just store the byte read into street1, street2, and street3. Note that with that code, there is no reason for street1, street2, or street3 to be int, when you send and receive bytes.