My childhood programming project!

This is probably my first (recorded) programming project. It was done in 2018 when I was just 12! I made it in my free time from school and won a small prize (an arduino modules kit) from the programming courses I was attending at the time. I still keep the kit and like to build some stuff with it in my free time.

What is this?

Looking back, the project was actually really simple:

I had a track loop with two alternative paths to the same (and only :) ) train station. The goal was to make a device that would automatically stop the IR-controlled train at the station, show a message about the train's arrival on the i2c LC display, and flip a switch by the servo every time it departs.

Schematic of the railroad.

Basically, the entire project started as I found an old TV remote and my father helped me to unsolder the IR LED, and then I found a fantastic legopowerfunctions library that was compatible with my train, which was the last piece that prevented me from creating the device.

Since at the time I didn't have a proximity sensor, I was forced to improvise a solution with a light detector: I placed a lamp on top of the station, and the light detector under the tracks, and when the train arrived, the light from the lamp was blocked by the train, and therefore the arduino knew when the train arrived by sensing a low signal from the sensor.

Picture of the layout.

Probably the most challenging part of this project was a poor quality of hardware. The effectiveness of the IR LED varied significantly on the direction it was pointed in, which made setting it up very annoying. At first, I tried to put it higher on the post made of legos, and when this did not work, i sanded down the surcafe of the LED. This solved the original issue, but it made the LED much weaker.

Picture of the upgrade with the light.

Another problem were servos: they were too weak, and the switch was too strong. At first, the cheap bootled sevos burned up, and the rotor started turning freely. When the old servos were replaced with the quality ones, the bootled chinese switches completely siezed up, and I was forced to buy the original lego switches.

In the end, despite all of the difficulties, this project was one of my most fun programming adventures. No amount of text will explain the amount of joy this seemingly trivial device brought in my life.

Picture of me and my sister at my desk

Source code

Original 2018 code:.ino source code

My attempt at rewriting it in 2021:.ino source code

The source code is only 69 lines long, and has no comments (as I didn’t like using them at the time). Looking back, this choice probably delayed completion of the project by weeks...