Advice for a newcomer to I2C

I have an Arduino based project for my model railway using an IR Remote to control solenoid point motors in accordance with the route selected. Each route selection can require parts (cases) of sketches on up to 6 Mega 2650 Boards to be fully completed. There are problems with the IR operating these sketches in the correct sequence and timing and I am forced to contemplate using I2C.

I propose to use On/Off toggle switches to input route selection to the analogue pins of three master Mega boards and use the existing six boards, with their existing sketches suitably modified, as slaves to execute that route selection.

Is such a scheme feasable and if so how is an analogue input transmitted to a slave in a form that will instruct to it execute the particular case in its' sketch for the route selected.

Any assitance or suggestions would be appreciated.

Many thanks

Philliph

what's your mother tongue?

Please, post a schematic (hand drawn one will be ok) that shows the connections of your 6 MEGAs, IR Sensors,, Motors etc. After that, I will try to show show you the connections among the MEGAs using I2C Bus for exchanging data/information. Also, post the sketch that you have already created.

My mother tongue is English

Schematic diagram and sample sketch attached below.

In the sketch the three letter designators ending in 'P' denote a point. Each point requires two solenoids to operate it, one for each direction of travel (N and R). The points have over centre locking mechaisms so the solenoid only requires momentary activation. Delays are incorporated to ensure only one solenoid fires at a time.

Interlocking ensures no conflicting routes are set.

The remaining designators are inputs and outputs to the track to control polarity for the route and point selection.

Sketches for Mega Boards 2 - 6 follow the same structure

Sketch bb4 mb 1.doc (111 KB)