Hello ! I have a very big problem and i want to resolve quickly . I have connected 2 arduinos nano by connecting their A4 , A5 , GND and 5v pins. Let's say that to the first Nano (Nano 1) i connected a pot and i read analog values ( i made 7 intervals for this values for ex first is from 0 to 146 ) and for values from 0 to 146 i send to Nano 2 a string '1'. If i have let's say values from 146 to 292 , Nano 1 write to Nano2 string 2 and so on. Also i have connected to this circuit a i2c lcd display(16,2) and i want to show on it strings which i get from Nano 1 to Nano 2 .Lcd i connected to A4 and A5 pins from Nano2 and 5V and GND. The problem is : when in the circuit i2c lcd isn't connected, i can read by Nano 2 those strings (with Serial) and when i2c is connected i can't see on Nano 2 strings from Nano and on lcd too. Which is the error?
Nano 1 (test1.ino) is the Master of the I2C bus.
It is flooding the I2C bus, because it writes data continuously.
Can you add a delay(250) at the end of the loop() to slow it down ?
Nano 2 (test2.ino) is the Slave of the I2C bus, yet it is the Master on the I2C bus for the display.
That means that both Arduino boards can be a Master. With a multimaster bus, you will have collisions. Your sketch is not prepared for that. The Wire library can detect a collision, but the Wire library can not detect every problem on the bus. That means it will not work.
You have to make one Arduino board the Master. A single Master for both the display and the other Arduino board.
The interrupt function "receiveEvent()" is too long. Keep it as short as possible. Don't use the Serial functions, since the Serial library uses interrupts itself. Your display is a I2C display, and you may not call the lcd functions from "receiveEvent()". It will issue a I2C communication while being inside the interrupt function of receiving I2C data.
There could be more problems, but these are the most obvious ones.