I was wondering if anybody has ever tried using the IRLink NXT sensor to make an automated train system and if so, what kind of setup did you have to make it all work?

I have been working on a train station for a while now and would like to create an automated system that will stop the train inside the train station for a set amount of time (maybe 30 seconds). As of now, I had an idea to use the touch and IRLink NXT sensors to make the system work. When a train approaches the station it will somehow hit the touch sensor. Then the IRLink sensor will send a signal to the IR receiver stopping the train inside the station. Then after 30 seconds, the IRLink sensor will send another signal to the IR receiver which starts the train. This will be continuous as the train track setup, as of now, is in a loop connecting both ends of the train station. I would also apply the same system on the opposing tracks in the station.

Am I overlooking anything that might make this not work? Are there any better alternatives to the touch sensor? Does anybody have any ideas as to how to avoid a collision within the train station if two trains are approaching less than 30 seconds apart? And finally, are there any experienced NXT programmers that could give me some advice on the programming aspect of the system?

I like this system because the train does not need any positioning awareness on the track for it to stop within the station every time.

  • 1
    Related: bricks.stackexchange.com/questions/1798/…
    – Ambo100
    Aug 26, 2014 at 22:58
  • Easier said than done guys ... I’ve been trying it for a year now. Arduino and Lego esp. with PF system are extremely complex and require advanced programming skills as well as expertise in coding.
    – Kyriacos
    Aug 3, 2018 at 14:30

1 Answer 1


I think I'd use the ultrasound sensor instead of the touch sensor (or the brightness sensor with the light turned on in a dark tunnel). I haven't tried this but I'd worry about the touch sensor derailing or scratching the train. Otherwse, your system sounds pretty doable. The collision risk could be addressed by setting up the sensor a little further before the station and sending a stop signal to the second train if it triggers the sensor while the first train is still at the station.

  • And if the train runs over a minifigure it would get stuck, so perhaps the train could be programmed to stop attempting to turn it's wheels if it detects a sudden drop in rotation speed. May 2, 2020 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.