Programming help with Toy Train Maintenance Project

I could use some help… I am currently enrolled in a computer science course (current class: ENG103 Internet of Things) and getting into the fun part of the class (my project).

You guys (and gals) have awesome support videos, but I will probably need some small tid-bits of help over the next week. I will be working heavily starting next week after my shifts this week.

I think I have successfully set up and used all sensors, but may need some help with missing pieces.

Project background

What is my (simulated) problem?:

  • Current rail maintenance programs can be modernised by tracking car cycles to determine when maintenance is due. (I’m sure techniques like this are already used, but it helps me understand on a grass-roots level of what is happening and it sounds good for the project J)
  • Maintenance area lighting efficiency can be improved by creating a ‘smart’ lighting system that is illuminated only while needed (and automatically turns off after a specified time).
  • Automated notifications can be sent when maintenance schedules are due (e.g. after certain number of rounds on the track.)

What is my solution?:

  • Use Python to track activity (keep lap totals) and send an SMS (notify a manager) when a specified level is reached (10 laps)
  • Use sensors to identify train position and identity and use Python code to control the lights

How will it work?:

Main points:

Simulated maintenance schedule:

Track the number of laps with RFID reader.

Add count by appending a list in Python (show using OLED display).

Flashes an LED when count reaches a certain level

Sends an SMS (Twilio) when a count is exceeded

Resets list count when IR break beam sensor is triggered (train on different ‘maintenance’ track)

Lighting: Use distance sensor to determine when train is within a certain distance (say 30 mm)

Use ‘sleep’ function to keep LED on for a specified amount of time (then shut off)

Extra security measures: Toy train has an LED light… Use the colour sensor to identify the train.

Possibly use the RFID reader as an additional verification.

Technical background / problems:

Project requires 3 sensors (minimum)

I am using the Piicodev adaptor… I would like to drive the LEDs for lighting…

Is there a video to show how to drive 1 or 2 LEDs (simulated lights) from a Piicodev terminal?

Is there a suggested method (or video) to incorporate the IR break-beam sensor?

I’ll be able to clarify my main questions next week, but thought to grease the wheels today to make sure I use the best forum.

Any additional thoughts on what would help or what I should avoid?

Thanks as always for what you do and your support.

Warm regards,


1 Like

What type of LED do you want to use? The generic 5mm LEDs or something else?

1 Like

Hi Rodger,

Sounds like you’ve got a good overall plan, can you give us some more specifics about your hardware?
You mentioned using a PiicoDev adaptor but not which microcontroller you were using.

If you’ve already got other PiicoDev modules working you could add your LEDs pretty easily using the PiicoDev RGB module.

Likewise there is an RFID module that belongs to the PiicoDev ecosystem as well as the colour sensor.

Your IR breakbeam sensor will just be a digital input signal, so you will just need a spare digital input pin for that one.

1 Like