Skip to content

4.1.11. Proximity Warning Radar

| Description In Project 66, learners will engineer an advanced 'Proximity Warning Radar' multi-component system. This design integrates HC-SR04 Ultrasonic + Active Buzzer + Traffic Light Module into a cohesive industrial automation unit.|------------------|----------------------------------------------------------------| | Use case |This project connects to real-world industrial and IoT applications such as: Project 66 provides essential master-level engineering skills for real-world IoT, safety, and control systems.|

Components (Things You will need)

Arduino Uno Arduino USB Cable Bread Board Jumper Wires Buzzer Ultrasonic Sensor Sound Sensor Traffic Light Module

Building the circuit

Things Needed:

  • Arduino Uno Core Board = 1
  • HC-SR04 Ultrasonic = 1
  • Active Buzzer = 1
  • Traffic Light Module = 1
  • USB Cable & Jumper Wires = 1
  • Bread Board
  • Sound Sensor

Mounting the component on the breadboard and wiring the circuit

Step 1: Let's get your circuit ready! Before you start, remember: Safety First! Always keep your USB power cable unplugged while you're connecting or moving any components.

Step 2: Get Ready: Gather all the modules listed in the "Required Components" table.

Step 3: Sensors In: Connect the sensor (Input) leads to the Analog/Digital pins on your Arduino. This is your system's "eyes" and "ears."

Step 4: Action Time: Connect the actuators and display (Output) leads to the PWM/I2C bus pins. This is how your project communicates!

Step 5: Power Up: Connect the VCC power lines to the 5V or 3.3V pins on your Arduino. These provide the electricity your components need.

Step 6: Ground It: Connect the GND (Ground) lines to any GND pin on your Arduino to complete the circuit.

Step 7: Safety Check: Double-check all your wiring! Make sure your VCC, 5V, 3.3V, and GND connections are correct to keep everything safe and sound.

Step 8: Final Step: Once you're confident everything is wired correctly, go ahead and plug in your USB programming cable to power up and start coding.

Step 9: Happy building!

Components on breadboard

Make sure to connect the Arduino USB cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Write the complete program implementing the system logic with appropriate pin definitions, setup configuration, and the main control loop.

// Project 66: Proximity Warning Radar
// Target Integration: HC-SR04 Ultrasonic + Active Buzzer + Traffic Light Module

const int trigPin = 2;
const int echoPin = 3;
const int redLed = 4;
const int yellowLed = 5;
const int greenLed = 6;
const int buzzer = 7;

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(redLed, OUTPUT);
  pinMode(yellowLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Serial.println("Project 66: Proximity Warning Radar Initialized...");
}

void loop() {
  long duration, distance;

  // Trigger sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read echo
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  // Logic control
  if (distance > 0 && distance < 10) {
    // Red Light + Buzzer
    digitalWrite(redLed, HIGH);
    digitalWrite(yellowLed, LOW);
    digitalWrite(greenLed, LOW);
    tone(buzzer, 1000); 
  } else if (distance >= 10 && distance < 25) {
    // Yellow Light
    digitalWrite(redLed, LOW);
    digitalWrite(yellowLed, HIGH);
    digitalWrite(greenLed, LOW);
    noTone(buzzer);
  } else {
    // Green Light
    digitalWrite(redLed, LOW);
    digitalWrite(yellowLed, LOW);
    digitalWrite(greenLed, HIGH);
    noTone(buzzer);
  }
  delay(200);
}

Step 7: Save your code. See the Getting Started section

Step 8: Select the arduino board and port See the Getting Started section:Selecting Arduino Board Type and Uploading your code.

Step 9: Upload your code. See the Getting Started section:Selecting Arduino Board Type and Uploading your code

CONCLUSION

The system responds dynamically when physical conditions cross pre-programmed setpoints, driving output devices reliably.