I have a question about the wire I2C library.
I want to communicate with an unknown number of buttons. Every button is connected to a microcontroller (I think I can use a ATTiny for that part). Every button has his own housing with LEDS. Every housing has one cable with 4 wires and a male connector. Every housing also has a female connector to daisy chain button housings to each other. There’s one master controller box where the first button connector goes into. So, every button has Ground, 5V and two data lines.
Now the master controller box wants to know if there’s a button pressed. Does the master controller box needs to poll every button-controller address to ask if the button is pressed? Or is there a way the button-controller can send to the master his button is pressed without being asked by the master? (very fast response after button press is important)
Follow up question: I don’t know the number of button’s the user has daisy chained up. So how does a new hooked up button gets automatically his own unique address and let the master controller know it’s available (without setting dip switches)? One thing I can think of is to give every button-controller address 127. Controller polls if address 127 is available, and if so, the controller gives the button-controller a new address. But this won't work if multiple buttons are connected at the same time, or if the master controll box is enabled after the connection has been made. :( Maybe disconnect the pass-trough dataline with a transistor and connect it after the button-controller has received a new adress?
Another option I thought of is to use the serial communication to communicate with each other. The RX is connected to the TX of the other controller and so on. The master RX is connected to the last TX button controller in the chain. And every button-controller needs to re-transmit the received serial data. If the button-controller has to say something itself, it injects his own serial data in the stream. One disadvantage is that I need to “terminate” or short the data wire’s on the last button connector otherwise the loop is open.