i need your support.
My plan is to control differend LEDs (on/off) which are connected to different PWM-Pin on the Master-Arduino by switches connected to slave arduinos. - So its a kind of change circuit w/ buttons which are connected to different Arduinos to avoid complex wiring.
The Arduinos are communicating via I2C.
If e.g. the floor-LED-Button on one slave arduino is pressed, the correct Pin on the Master Arduino is changing its state (On / Off).
I'm wondering how to setup the control in a smart way. I thought about to send a char which identifies the correct LED. A general function is using this char as input and changes the state of the PIN. Like this example (based on a single Arduino setup:
Do some research about how I2C works, what it offers. As I got it the master will need to call each slave for a slave message. What data types to use, You look for that.
Searching for electrical data will be useful as the total number of devices might call for suitable pullup resistors on SDA and SCL.
Why not post a concept block drawing showing wiring lengths, links to technical info on hardware items you have chosen. This has a big impact on what I would recommend to use. The information you pass to control things is up to you. Using a character is a good way to start, you can see that on the monitor. You learn the concept that way and later expand upon it. There many standards which make it easier but they do not need to be followed.
Thanks for your feedback & sry for the unclear description.
@Railroader : Yes, im currently reading in parallel how the I2C bus works. I just wanted to get a direction from an expert how to realize such a system. thx. @gilshultz@lastchancename : Below a diagram with some additional information.
I have 4 different buttons (not switches) per arduino. I have at least 2 Arduino to control the lamps.
In addition I would like to alluminate all 4 buttons independently.
The buttons are located direct next to the arduino.
If I wire all buttons to 1 Arduino I would need to connect 2 cables per switch (Button Signal & the 5V for illuminating). This would be in general possible but the SW solution is definitely the smarter way. Especially when I would like to extend the system in future.
Using I2C between disparate devices seems risky…
if I recall, the spec roughly defines about 600mm max length ( its intended to run between ICs, not modules.)
Any reason you’re not just using spare pins on the MEGA to detect the switch states… there are several options ?
The low frequency of button pushes at 5V makes them very easy to debounce / filter etc
From what you’ve explained so far, a MEGA2560 could do everything easily, with less risk & complexity.
If you’re intent to use a MEGA and 4xUNO slaves, that’s not a problem…
The MEGA has FOUR serial ports (including the USB/console), or… if you’re keen, you could multi-drop the slaves off a single port of the host…(e.g.RS485)
For what you’ve drawn, I’d still think seriously about a single MEGA2560 doing everything.
Just plan your buttons & LEDs before you start, and you’ll be golden.