Table of Contents

DIY Automatic Railway Crossing

Automatic-Railway-Crossing
Project Description

Introduction

Christmas is just around the corner and many of us are still wondering what to get as a gift for our kids, siblings, and cousins. Train sets have been one of the most popular and enjoyable gifts for a long long time. This year, how about adding a DIY twist to it so that they can also learn a thing or two while building and playing with their train set?

Presenting to you the DIY automatic railway crossing – an easy to build yet engaging project that gives an idea of how railway crossings work whenever a train passes by. Your kids, siblings, and cousins are sure going to have an amazing time with it!

Want to make one? We’ll show you how!

Making

Take the white cardboard sheet and mark the outline of your track and road.Marking of the railway crossign

Paste a green piece of paper on the cardboard to indicate where the path will be.Adding green patch

Attach the railway track on the cardboard As per the outline you made. Here, we have 3D printed our railway track.Adding Railway Track

Glue pieces of the black coloured paper on both the sides of the track; they will work as the road.Making of Road 1 Making of road2

To add more details, we have added the solid white markings on both the sides of the road and broken white marking in the centre of the road.Solide White Marking 2 Broken White Marking 1 Broken White Marking 3

Now, we know that at the crossing, barriers are mounted to stop the vehicles while the train passes by.

Now, add the barriers to your railway crossing.
We will be using two servos.

Glue the foam sheets on both the sides of the servos.Servo in Foam Sheet

We have fixed as well covered the servos using red tape.
Make sure you keep the servo head out of the tape.

Attach the servo horns on the free servo heads.Adding the Servo Horn

Now that the barrier mechanism is complete, we need to make the barriers.

Attach two long sticks on the servo horns.Adding the barriers

Now, glue the barriers on both the sides of the track.Glue the Barries

We need something to detect the arrival of the train. For that, we are going to use the Ultrasonic Sensor.
Mount an ultrasonic distance sensor with its holder beside the crossing.Adding Ultrasonic Sensor

Now, to add a touch of the real world, we will add some artificial plants and stones.Add Plants 1 Add Stones

The assembly will be completed once you make the connections as shown in the next step.Complete Assembly

Connections

Make the connections as shown. 
Also, make sure that all the wiring should be done under the white sheet.railway-fritzing-diagram

Logic and Flowchart

The logic is very simple: if the ultrasonic sensor detects the train (distance sensed by the sensor is less than a threshold value, say 10cm), the barriers (servo horns) will close. They will automatically open after a few seconds, i.e. the servo horns will automatically return to their start position.Flowchart

Code

The following Arduino Code should be uploaded to evive.

Working

The train is not detected hence the barriers are open.Barriers are Open

Once the train is detected the barriers are closed.Barriers are closed

Conclusion

With this, your DIY automatic railway crossing is now up and standing to warn cars whenever a train passes by! Enjoy!

Project Downloads - Code and Files

Circuit Diagram

Circuit Diagram DescriptionCircuit Diagram Fritzing Diagram

Make the connections as shown. 
Also, make sure that all the wiring should be done under the white sheet.

Explore Related Projects by STEMpedia

Level up your robot control skills by learning how to control a 2-Wheel Drive Robot with hand gestures using PictoBlox AI's Machine Learning extension. Get ready to channel your inner Jean Grey!
Learn how to make a two-wheel-drive robot and code on the go with PictoBlox's mobile app. Control your robot in real-time with your smartphone!
Learn how to make an automatic chocolate dispenser to delight Santa this Christmas. All components can be found in the evive Starter Kit. Let's begin!

Explore Community Projects