Hello everyone. I am a beginner at using Arduino UNO and I have never dealt with using multiple Arduino boards before. I am planning to make a project which utilizes ultrasonic sensor on each of the 5 boards such that when the first sensor is triggered, the LEDs of the first and second board will light up and when the second sensor is triggered, the LEDs of the second and third board would light up and so on.
I have no experience with this whatsoever and based from my preliminary research, I2C can be used but from what I have seen, the tutorials online only show two boards being connected with the one being the master and the other the slave but as it is, I want my boards to have the same degree of independence since I need them to follow that specific pattern. Now, is it possible to connect the five boards such as that they can send or receive signal from each other or do I have to go with 1 master and 5 slaves approach? If there is another way, feel free to reply and please send sample codes if you can. I'd appreciate all help but I do have to remind you guys that I'm basically an infant at this.
I have a similar question currently. As far as I know, with I2C you either need to find a workaround (such as making all the data be sent to the master and then back to the slave) or modify the library, which probably is very hard.
The workaround case, would be that the master is constantly requesting data to each slave, and the slave may respond 0, meaning that he has nothing to report. Many I2C peripherals work like this. For example an MPR121 capacitive sensor must be asked periodically if there is a touch (actually it does have a pin that can interrupt the arduino, but that is outside the I2C protocol, and you can do without)
There is also the RS485 standard, that allows many devices to be connected to the same bus as in I2C, but it is not tied to a protocol. It would be on your own about how to avoid message collisions.
If it's not a problem for you to add more wires, you could add some additional communication among arduinos. For example, the role of the emitter could be granted by a dedicated pin that is connected between the MCU's, perhaps making a ring that loops this permission (called 'token').
There are also these nice RF based modules that are a bit of dark magic. But the result is a very fast, wireless and conflict-less communication among many devices. (the library is RF24Mesh here and it has a link to the module to buy) The problem I personally have with this module is that is not full duplex, but half duplex.
Other interesting approach, again depending on your limitations, is to use Ethernet.
A different phrasing of your post title will attract better answerers, because just networking 5 arduinos in I2C is easy.
Keep in mind that I2C is only suited for short range. With short range I mean < 5 meter (maybe even less) You didn't say how far the Arduinos are apart from each other.