Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Automatic Railway Crossing Using Arduino

This is a simple college project. It automatically turn off the railway gate when train arrival and after
train departure.

Step 1: Collect the Material

 Arduino UNO (Or other)


 L293d motor driver ic or shild
 Two IR sensor
 one Dc geared motor 30 RPM
 12volt Power supply (SMPS)
 A toy train
 A cardboard (as base)
 solder
 hot melt gun
 A buzzer
 A wooden or plastic rod for gate
 some wires, screws

Step 2: Fix the Material on Cardboard

1. fix the track on cardboard as shown in pic or in my youtube video, link shown below
https://youtu.be/1Oc5R_yByNw
you can fix this by using hot melt glue, screw, rubber strip.
2. Fix the moter on cardboard as shown in pic by screw or rubber strip.
3. Connect a plastic or wooden rod to motor's axis, this is used as gate.
4. fix two IR sensor in both side of gate(motor) and should be at equal distance as shown in my
video https://youtu.be/1Oc5R_yByNw
5. Remove the LED's from circuit of sensor and fix opposite to PHOTO TRANSISTOR and connect by
wires

Step 3: Circuit Connection and Wiring

circuit diagram is shown in pic.

1. connect the IR sensor's Vcc and GND pin to Arduino


2. connect the output pins of IR sensors to Arduino's pin no 2 and 3

3. connect the pin no 4 and 5 of Arduino to L293D's input pins as shown in circuit.

4. connect the motor as shown in circuit.

5. connect all the connection as shown in circuit.

6. also connect the buzzer to both motors pins.

Step 4: #program and Code

here code is shown

just copy and paste it

int sensor1=2;

int sensor2=3;

int motor1=4;

int motor2=5;

void setup(){

pinMode(sensor1,INPUT);

pinMode(sensor2,INPUT);

pinMode(motor1,OUTPUT);

pinMode(motor2,OUTPUT);
}

void loop(){

C:

if(sensor1==LOW){

digitalWrite(motor1,HIGH);

digitalWrite(motor2,LOW);

delay(500);

digitalWrite(motor1,HIGH);

digitalWrite(motor2,HIGH);

A:

if(sensor2==LOW){

digitalWrite(motor1,LOW);

digitalWrite(motor2,HIGH);

delay(500);

digitalWrite(motor1,HIGH);

digitalWrite(motor2,HIGH);

delay(1000);

goto C;

}goto A;

if(sensor2==LOW){

digitalWrite(motor1,HIGH);

digitalWrite(motor2,LOW);

delay(500);

digitalWrite(motor1,HIGH);
digitalWrite(motor2,HIGH);

B:

if(sensor1==LOW){

digitalWrite(motor1,LOW);

digitalWrite(motor2,HIGH);

delay(500);

digitalWrite(motor1,HIGH);

digitalWrite(motor2,HIGH);

delay(1000);

goto C;

goto B;

here 500ms delay is used because gate is closed in this time. you can change this according to practical
response

You might also like