What sensor for lego arduino project

Hey Guys,

I am looking to build me son an automated level crossing for his Lego train track.

I was thinking of driving 2 stepper motors from one driver, to lift and lower the barriers.

I was then planning on having two sensors on the track, before the crossing and after the crossing to detect when the train is coming and also when the train has passed.

What would be the best type of sensor that detection?
Motion?
Light?
Any others.

Any help would be greatly appreciated.

I would nrmally use an IR proximity sensor like this one:

For lifting the boom gate you could use a solenoid (like below) but don’t try to drive it directly from the sensor. You’ll need a transistor to drive it. Core-Electronics have an article on doing this on their site (https://core-electronics.com.au/tutorials/solenoid-control-with-arduino.html). You don’t need to use the Arduino because the sensor can provide the output to drive the transistor.

1 Like

I would also recommend doing a web search for something like “Lego railway arduino projects”. You will probably find quite a few projects that do what you need, and you might be inspired to lock the door and keep those pesky nippers of YOUR trainset. :grin:

1 Like

Thanks a lot, I hadnt considered a solenoid. Great idea.

1 Like

Ha ha, thanks Robin. Will do a search now.

1 Like