Model train crossing signals

Reply #6 is my preferred way to go, with added ‘debounce’ awareness, that will be the simplest, and easiest way to ignore track dirt.

One Arduino could service multiple track sections)

(It could be even simpler, using a ‘retriggerable one-shot’ driving the accessory, Your choice)

The $120 isn’t much in real world terms, but if you include your time & labour cost, it’s probably going to cost about the same in the end.

The choices are yours.