Wave to get the Train moving

Wave to get the Train moving

Shortly after Christmas 2018 my good friend Marco (from CODA FabLab and CoderDojo) thought it was a good idea to create an interactive little contraption in the basement of the Apeldoorn public library (Netherlands). The train is heavily inspired by the 1981 set Electric Passenger Train but with a 9V electric motor underneath. So I decided to use the color sensor and 2 touch sensors of the Mindstorms NXT 2.0 set together with the NXT Intelligent Brick because we could not spare any EV3 parts…

Kids (but also a lot of adults) are waving their hand in front of the sensor to make the train move from one buffer stop to the other, showing working headlights while driving. Both buffer stops contain a touch sensor. It has been running in the display case ever since. I only had to clean the track once and had to readjust the color sensor because it moved away from the window a bit, causing it to no longer see waving hands… More technical details can be found below the videos/images.

This is the test phase on my desktop at home:

And this is the setup in the display case in the library:

The code was written using the NXT-G programming software and you can download the CodaTrain.rbt file here. Below is a screenshot of the complete program:

It contains of an infinite loop waiting until something inside the color range from blue until and including red is spotted by the color sensor, like so:

Then motor output A is powered. To be able to adapt an NXT connection to a 9V Train Connection Wire I used a Mindstorms NXT Converter Cable.

So output A is powered until touch sensor 2 is touched, then the power to output A it cut. Again the waiting is for something to move in front of the color sensor (same code is used as shown above). When this happens, output A is powered in the other direction, to reverse the train ride. Until sensor 1 is touched, etc…

The NXT Intelligent Brick is powered by the Rechargeable Battery for LEGO Mindstorms NXT which is ultimately connected to a regular 220V electrical outlet coming from the ceiling of the library


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s