กลับไปหน้ารวมไฟล์
automated-rail-crossing-system-sheekar-banerjee-886da1-en.md

Diorama Realism: Automated Rail Crossing

The Automated Rail Crossing System (popularized by makers like Sheekar Banerjee) transforms a static model railroad diorama into a living, responsive world. It integrates servo positioning with asynchronous LED flashing logic to mimic real-world warning signals flawlessly.

Circuit Planning:

Arduino to Ultrasonic Sensor Arduino -----> HC-SR04 Vin -----> Vcc GND -----> GND 2 -----> trigPin 3 -----> echoPin

Arduino to Servo Motor Arduino -----> Servo Motor Vin -----> Red wire (+) GND -----> Black or Dark wire (-) Digital pin 9 -----> Yellow/Orange wire (data)

EXPANDED TECHNICAL DETAILS

Non-Blocking Asynchronous Flashing

The hardest part of this project is the Warning Lights.

  • A real railroad crossing has two red lights that flash in an alternating pattern: left, right, left, right.
  • If you code this using delay(500);, the Arduino processor completely freezes. It wouldn't be able to listen to the sensors to know if the train had passed!
  • You must use the millis() logic structure (The "Blink Without Delay" technique).
  • if (currentMillis - previousMillis >= 500) { toggleLights(); }
  • This allows the Arduino to flash the massive warning LED stanchions flawlessly while simultaneously calculating the approach speed of the train.

Actuating the Boom Gates

  1. The Approach: A TCRT5000 IR Sensor is buried under the track, 3 feet before the road crossing.
  2. The Arduino detects the train. It immediately starts the asynchronous LED flashing sequence.
  3. It commands two SG90 Micro Servos (hidden under the road) to slowly rotate 90 degrees, dropping the boom gates.
  4. The Departure: A second IR Sensor is buried 3 feet after the road crossing. When the train's caboose clears the second sensor, the Arduino raises the boom gates and turns off the warning flashers!

Scenery Component List

  • Arduino Uno/Nano: The dispatch center.
  • IR Obstacle Sensors (x2) or Light Dependent Resistors.
  • Micro Servos (SG90 x2).
  • Red LEDs and 220-ohm Resistors (x4) integrated into plastic 3D-printed crossing totems.
  • MP3 Sound Module (Optional: To play the loud "Ding-Ding-Ding" crossing bell from a micro-SD card!).

Code:

//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 3
}
void loop() {
 long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 duration=pulseIn(echoPin, HIGH);
 distance=(duration/2)/29.1;       //Calculation of distance
 if(distance<10)
 {
   sm.write(80);
 }
 else {
   sm.write(0);
}
}

Results:

Automated Rail Crossing System | Sheekar Banerjee

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "sheekar"
category: "Motors & Robotics"
components:
  - "1x SG90 Micro-servo motor"
  - "1x Arduino UNO"
  - "1x Ultrasonic Sensor - HC-SR04 (Generic)"
description: "Stand clear of the tracks! Bring absolute scale realism to your model train layout by programming IR detectors, dropping boom gates, and flashing warning stanchions."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX187K3R1bzCCqaEiugm8mlWK6JmptNsNVnAfRwCd7I3UspmsmQO5/2oI03JXjWc0zMNxYcAKIo2EivKln7oHa9TscKQPctId34A="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/automated-rail-crossing-system-sheekar-banerjee-886da1_cover.jpg"
lang: "en"
likes: 0
passwordHash: "2f2c9b00f91e3ff462c81d5abee4f588b1e4e0348aacd8c1dff38ae2601d7b38"
price: 1120
seoDescription: "Automated Rail Crossing System project developed by Sheekar Banerjee and the SENSO CODER research team in December 2017."
tags:
  - "embedded"
  - "smart appliances"
  - "human welfare"
  - "passenger vehicles"
  - "internet of things"
  - "monitoring"
title: "Automated Rail Crossing System | Sheekar Banerjee"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/6h3EgZV3Rgc"
views: 1335