Froggy World 4 the Train




Introduction: Froggy World 4 the Train

About: I am an author and a maker. My current project is Santa's Shop. I'm working on a science fiction type book--more later. @EngineerRigsby

In Froggy World, the amusement park for adventurous frogs, we have catapulted, booted and seesawed Froggy.  Upon departing the seesaw Froggy must land in a waiting train car. 

The train must be large enough to carry frogs (O scale) and must stop at precisely the right spot to receive passengers.  Stopping the train at a precise spot (not give or take an inch) is somewhat challenging.  Voltage from the supply varies throughout the day.  Voltage dips when heavy loads start in the house.  Voltage at the train engine depends upon track connections and wheel connections.  The train engine is an imprecise electromechanical device. 

The method of control I settled on requires detecting the position of the train with a magnetic switch (relay actually), then shutting the motor off and "crashing" the train into a stop sign. 

The system uses 3d printed parts:

and an Arduino for logic control.

Step 1:

Let's start with something that didn't work too well.  I set up a photocell and photoresistor--and they reliably detected the train--but I had 3 to 4 inches of variance in where the train actually stopped after detection.

Step 2:

Using a reed relay (Jameco #111448) and a bar magnet glued to a train car, I was able to get my "variable stopping distance" down to about one inch.

Connect wire wrap wire across the relay contacts--the relay will close when the magnet is near.

Step 3:

The stop arm is mounted to the servo horn (HiTec HS-311 servo, using #4-40 machine screws.

Step 4:

Using 4 x 3/4 wood screws, I mount the servo/arm assembly and support brace (opposite side of track) to the plywood base.

Step 5:

I wired the servo/arm, magnetic switch and relay (to control the train) in accordance with this schematic.

I put the following code into the Arduino:

#include <Servo.h>

Servo gate;

int start=10;

int next=7;

int dummy=0;

int train=5;

int arrival=1;

int val=0;

int val2=0;

void setup()

{gate.attach (3);

pinMode (next, OUTPUT);

pinMode (start, INPUT);

pinMode(arrival, INPUT);

pinMode (train, OUTPUT);

digitalWrite (next, HIGH);

digitalWrite (train, LOW);




void loop()


if(val==LOW or dummy==1)



delay (500);








{digitalWrite (train, LOW);






Step 6:

With the servo disconnected and arm up, adjust the train speed such that the engine always rolls to a stop just beyond the arm.

Now, enable the arm and the train WILL stop at the stop sign!

UP! Contest

Participated in the
UP! Contest

Be the First to Share


    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • CNC Contest 2020

      CNC Contest 2020
    • Secret Compartment Challenge

      Secret Compartment Challenge

    7 Discussions


    Reply 7 years ago on Introduction

    For the led sensors, look at:

    and you will see a diagram using 5 volt power with a resistor and led in series (to light the led) and 5 volt power with a resistor and photocell in series. The voltage across the photocell changes when light changes--that is sent to an analog input of the Arduino to determine when the light beam has been broken.

    The magnet and relay does not require a microcontroller to be useful. The contact on the relay closes when the magnet passes by; you can use this contact closure for whatever purpose you need.


    Reply 7 years ago on Introduction

    Any way to do it without an Arduino?


    Reply 7 years ago on Introduction

    If you took the resistor/photocell in series and (from the mid point of that combination) took a wire to the base of a transistor, that transistor could be used to operate a relay. You would have to play with the resistor value to get the right combination, based upon your photocell, transistor and relay.


    Reply 7 years ago on Introduction

    I'll look into making an instructable on this in the next day or two.


    Reply 7 years ago on Introduction

    Here's more information:


    7 years ago on Step 6

    You could briefly(very breifly) reverse the trains motor to "Brake" the train, at your detector that should decrease your stopping distance.