Sheekar Banerjee
Published © CC0

Automated Rail Crossing System | Sheekar Banerjee

This project was developed in December 2017 by a very newborn research team SENSO CODER, founded by Sheekar Banerjee.

IntermediateShowcase (no instructions)97
Automated Rail Crossing System | Sheekar Banerjee

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram of Automated Rail Crossing System

Code

Program of Automated Rail Crossing System

Arduino
//the code is entirely created by: SHEEKAR BANERJEE (at December 2017)
//Dept. of CSE, IUBAT
//AI-ML-IOT Solution Engineer and Researcher


#include<Servo.h>  //This calls the Header of the repository containing the library files of Servo Motor Driver Modules
#define trigPin 2  //This initializes the Trig pin of HC-05 Ultrasonic Sensor to the pin no. 2 of Arduino Microcontroller
#define echoPin 3 //This initializes the Echo pin of HC-05 Ultrasonic Sensor to the pin no. 3 of Arduino Microcontroller

Servo sm;     //Servo is a Class which is providing an independent data type // sm is a variable which is representing the servo motor

int sound=250;

void setup() {
 Serial.begin(9600); //Streaming 9600 bits of sensor data per second
 
 pinMode(trigPin,OUTPUT); //Here, Trig pin triggers the electrical impulses into the sensor as an output
 
 pinMode(echoPin,INPUT);  //Here, Echo pin inputs the reflective signals into the sensor
 
 sm.attach(9);   //Servo motor data pin is attached to Arduino Digital Pin 9 
}

void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);        // It will wait for 2 microseconds after every single electrical implulse of Trig pin if it is sending LOW(less than 1.6V) signal
  
  digitalWrite(trigPin, HIGH); 
  delayMicroseconds(10);       //It will wait for 10 microseconds after every single electrical implulse of Trig pin if it is sending HIGH(greater than 1.6V) signal
  digitalWrite(trigPin, LOW);


  duration=pulseIn(echoPin, HIGH);  //Sensor inputs the signal through the Echo pin
  distance=(duration/2)/29.1;       //Calculation of distance
 
 if(distance<10)    //According to the reflection time calculation, if the distance is less than 10 cm  
 {
   sm.write(80);      
 }
 else { 
   sm.write(0); //The Servo Motor will rotate for 80 degrees     
} 
}

Credits

Sheekar Banerjee
0 projects • 6 followers
A motivated Computer Scientist & Engineer with years of experience over IoT, Robotic Systems, Machine Learning Algorithms and Software.
Contact

Comments

Please log in or sign up to comment.