. ~ SmartElectronicsDIY

 

🔷 Project Overview

This system allows an ambulance to send an emergency alert wirelessly using LoRa to nearby traffic junction control units, which then automatically clear the path by turning traffic lights green and displaying emergency messages.

LoRa is used because it supports:

  • Long-range communication (2–10 km)

  • Low power

  • No internet required





🔷 System Block Diagram (Concept)

[ Ambulance Unit ] Button → Arduino → LoRa TX ))))))) LoRa RX → Arduino → LCD ↓ Traffic Lights

🔧 Hardware Components

🚑 Ambulance Unit (Transmitter)

🚦 Traffic Control Unit (Receiver)

  • Arduino UNO

  • LoRa Module (SX1278 / RA-02)

  • 16x2 LCD (I2C or normal)

  • Red, Yellow, Green LEDs (Traffic lights)

  • Buzzer


🔌 LoRa Module Pin Connections (SX1278)

LoRa PinArduino UNO
VCC3.3V ⚠️
GNDGND
NSSD10
MOSID11
MISOD12
SCKD13
DIO0D2

⚠️ Do NOT connect LoRa to 5V


🚑 TRANSMITTER CODE (Ambulance Unit)

#include <SPI.h> #include <LoRa.h> #define BUTTON 4 #define BUZZER 5 void setup() { pinMode(BUTTON, INPUT_PULLUP); pinMode(BUZZER, OUTPUT); Serial.begin(9600); LoRa.setPins(10, 9, 2); // NSS, RESET, DIO0 if (!LoRa.begin(433E6)) { Serial.println("LoRa Failed!"); while (1); } Serial.println("Ambulance LoRa Ready"); } void loop() { if (digitalRead(BUTTON) == LOW) { digitalWrite(BUZZER, HIGH); LoRa.beginPacket(); LoRa.print("EMERGENCY_AMBULANCE"); LoRa.endPacket(); Serial.println("Emergency Sent"); delay(2000); digitalWrite(BUZZER, LOW); } }

🚦 RECEIVER CODE (Traffic Control Unit)

#include <SPI.h> #include <LoRa.h> #include <LiquidCrystal.h> LiquidCrystal lcd(7, 6, 5, 4, 3, 2); #define RED 8 #define YELLOW 9 #define GREEN 10 #define BUZZER 11 void setup() { pinMode(RED, OUTPUT); pinMode(YELLOW, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BUZZER, OUTPUT); lcd.begin(16, 2); lcd.print("Traffic System"); Serial.begin(9600); LoRa.setPins(10, 9, 2); if (!LoRa.begin(433E6)) { lcd.print("LoRa Failed"); while (1); } } void loop() { int packetSize = LoRa.parsePacket(); if (packetSize) { String message = ""; while (LoRa.available()) { message += (char)LoRa.read(); } Serial.println(message); if (message == "EMERGENCY_AMBULANCE") { lcd.clear(); lcd.print("EMERGENCY!"); lcd.setCursor(0, 1); lcd.print("CLEAR PATH"); digitalWrite(RED, LOW); digitalWrite(YELLOW, LOW); digitalWrite(GREEN, HIGH); digitalWrite(BUZZER, HIGH); delay(8000); // Path cleared time digitalWrite(GREEN, LOW); digitalWrite(RED, HIGH); digitalWrite(BUZZER, LOW); } } }

⚙️ Working Explanation (Step-by-Step)

  1. Ambulance driver presses emergency button

  2. Arduino sends EMERGENCY_AMBULANCE message via LoRa

  3. Receiver unit receives alert

  4. Traffic light turns GREEN

  5. LCD shows EMERGENCY – CLEAR PATH

  6. After ambulance passes, normal traffic resumes








🏥 Applications

  • Smart traffic systems

  • Emergency vehicle priority

  • Smart city projects

  • Highway emergency management


🌟 Advantages

✔ Long range (no internet)
✔ Fast response
✔ Low power
✔ Scalable to many junctions


📌 Future Enhancements

0 comments:

Post a Comment