Need advices with a project including lego train and leds

Below this text is an small "schema" how I want it to work with lego train and leds. The trafficlights are made By leds. I don´t need a complete code just what kind of components (sensor) and perhaps
some advice about the programming to code and other things. I'm using Arduino Uno for this Project.

1 Stop the train with sensor at trafficlights 1 and trigger trafficlights 2 to switch from green to red.

2. When trafficlights 2 is switched to red then trigger trafficlights 1 to switch from red via yellow to green.

3. Train start when trafficlights 1 is switched to green and another sensor trigger trafficlights 1 to switch                          from green via yellow to red.

4. When trafficlights 1 is red then switch trafficlights 2 from red to green.

How do you propose to control the Lego? Is it by using IR remote control or by direct wiring?

Grumpy_Mike:
How do you propose to control the Lego? Is it by using IR remote control or by direct wiring?

By using IR and wihtout remote controller, the train should run automatically, stop and start without By itself. intefernce

Your steps describe the automaton which you should implement.

Therefore you need to implement the Lego IR protocol in the Arduino.

I did reverse engineer this protocol for a book I wrote:-

So I can't publish it here because of copy write with the books publishers, but it is not difficult. The book has code in Python for the Raspberry Pi but the protocol is the same.

It is the same protocol used in the IR controller for the EV3 mind storms system.

Grumpy_Mike:
Therefore you need to implement the Lego IR protocol in the Arduino.

I did reverse engineer this protocol for a book I wrote:-
Raspberry Pi Projects For Dummies | Wiley
So I can't publish it here because of copy write with the books publishers, but it is not difficult. The book has code in Python for the Raspberry Pi but the protocol is the same.

It is the same protocol used in the IR controller for the EV3 mind storms system.

Thanks for this advice. I have obtained the book and it seem to be very interesting book.