Site icon Circuit Ideas for You

Railway Track Accident Prevention Circuit using Arduino

Railway accidents happen because obstacles come on railway track, because many trains cannot stop fast; therefore, this project uses Arduino Uno, ultrasonic sensor, relay and motor or servo to give warning or stop mechanism.

The system checks distance and if object comes close, relay activates and motor moves barrier or alarm system, also this helps to avoid accidents in simple low-cost way.

Additionally, this Railway Track Accident Prevention Circuit using Arduino is easy to build.

Arduino Code:

const int trigPin = 9;
const int echoPin = 10;
const int relayPin = 7;
const int servoPin = 6;

long duration;
int distance;

#include <Servo.h>
Servo myservo;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(relayPin, OUTPUT);
myservo.attach(servoPin);
myservo.write(0);
digitalWrite(relayPin, LOW);
Serial.begin(9600);
}

void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;

Serial.println(distance);

if (distance < 20) {
digitalWrite(relayPin, HIGH);
myservo.write(90);
} else {
digitalWrite(relayPin, LOW);
myservo.write(0);
}
delay(200);
}

Coding Explanation:

Circuit Working:

Railway Track Accident Prevention Circuit Diagram using Arduino

Parts List:

ComponentsQuantity
Arduino Uno1
Ultrasonic Sensor HC-SR041
5V Relay Module1
Servo Motor (SG90)1
DC Motor 1

Arduino gives 5V power to ultrasonic sensor and to servo, trig pin sends pulse and echo pin reads reflection.

Then relay module gets 5V and signal from Arduino digital pin and also this relay can drive a DC motor or alarm.

Hence, when the sensor detects an object nearby, the relay activates and starts the motor or alarm, then, the servo rotates to show the gate closing.

Finally, all devices share common ground.

Formulas:

Ultrasonic distance formula:

Distance = (time x speed of sound) / 2

Speed of sound in air approx 340 meter per second

In microseconds speed about 0.034 cm per microsecond

So distance = duration x 0.034 / 2

Division by 2 because pulse travels to object and back.

How to Build:

To build a Railway Track Accident Prevention Circuit using Arduino follow the below steps:

Conclusion:

To conclude, this project for Railway Track Accident Prevention Circuit using Arduino gives simple method to avoid railway accidents.

Here, system detects object on track using ultrasonic sensor and then Arduino controls relay and servo to give warning or close barrier.

This project costs very little and works reliably, also we can install it on small rail crossings or demo models because it increases safety and reduces human error.

Exit mobile version