This circuit is designed to manage runway clearance and emergency alerts using an Arduino UNO. It includes LEDs to indicate runway status, a buzzer for emergency alerts, and an ultrasonic sensor for additional functionality. The system also includes resistors to limit current to the LEDs and a button to request runway clearance.
LED: Two Pin (red)
LED: Two Pin (green)
Resistor (200 Ohms)
Arduino UNO
Resistor (200 Ohms)
Buzzer
Ultrasonic Sensor
// Pin definitions
const int greenLED = 9; // Runway clear LED
const int redLED = 10; // Emergency LED
const int requestButton = 2; // Button to request clearance
const int buzzer = 8; // Buzzer for emergency alert
// Variables to keep track of states
bool runwayClear = true; // Indicates if runway is available
bool emergencyActive = false; // Indicates an emergency
unsigned long lastEmergencyTime = 0; // Last time an emergency occurred
unsigned long nextEmergencyDelay = 20000; // Minimum 20 seconds
void setup() {
// Set up pin modes
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(requestButton, INPUT_PULLUP); // Using INPUT_PULLUP for stable button reading
// Initial conditions - all indicators off
digitalWrite(greenLED, LOW); // Green LED off
digitalWrite(redLED, LOW); // Red LED off
digitalWrite(buzzer, LOW); // Buzzer off
Serial.begin(9600); // Begin serial communication for debugging
// Seed the random number generator
randomSeed(analogRead(A0));
// Schedule the first random emergency
scheduleNextEmergency();
}
void loop() {
// Check button press
if (digitalRead(requestButton) == LOW) {
delay(5); // Debounce delay
if (digitalRead(requestButton) == LOW) { // Confirm button press
handleRunwayRequest();
}
}
// Handle emergency timing
if (millis() - lastEmergencyTime > nextEmergencyDelay) {
activateEmergency();
scheduleNextEmergency();
}
}
// Function to handle runway clearance requests
void handleRunwayRequest() {
if (!emergencyActive && runwayClear) {
Serial.println("Clearance Granted: Aircraft may proceed.");
digitalWrite(greenLED, HIGH); // Green LED on to signal clearance
delay(3000); // Simulate runway usage (aircraft taking off/landing)
resetRunway(); // Reset runway to clear state
} else if (emergencyActive) {
Serial.println("Emergency Override: Runway unavailable.");
} else {
Serial.println("Runway Occupied: Please wait.");
}
}
// Function to reset the runway
void resetRunway() {
runwayClear = true;
digitalWrite(greenLED, LOW); // Turn off green LED (runway is no longer cleared)
Serial.println("Runway is now clear.");
}
// Function to activate emergency mode
void activateEmergency() {
emergencyActive = true;
digitalWrite(redLED, HIGH); // Turn on red LED
digitalWrite(buzzer, HIGH); // Sound the buzzer
Serial.println("Emergency Activated: Priority landing.");
// Simulate emergency duration
delay(2000);
deactivateEmergency();
}
// Function to deactivate emergency mode
void deactivateEmergency() {
emergencyActive = false;
digitalWrite(redLED, LOW); // Turn off red LED
digitalWrite(buzzer, LOW); // Turn off buzzer
Serial.println("Emergency Cleared: Resuming normal operations.");
}
// Function to schedule the next random emergency
void scheduleNextEmergency() {
lastEmergencyTime = millis();
nextEmergencyDelay = 20000 + random(0, 10001);
Serial.print("Next emergency in ");
Serial.print(nextEmergencyDelay / 1000);
Serial.println(" seconds.");
}
This code manages the runway clearance and emergency alerts. It uses the Arduino UNO to control LEDs, a buzzer, and an ultrasonic sensor. The code includes functions to handle runway requests, activate and deactivate emergencies, and schedule random emergencies.