About the Project

The Accident Avoiding Car is an innovative project designed to enhance road safety through autonomous obstacle detection and avoidance. Using advanced sensor technology, this system can detect obstacles in real-time and take preventive actions to avoid collisions.

This project uses an Arduino UNO microcontroller combined with an ultrasonic sensor to measure the distance to obstacles. When an object is detected within 20cm, the system automatically stops the car by activating a relay module that controls the motors.

Arduino Based

Powered by Arduino UNO for reliable control

Ultrasonic Detection

Real-time obstacle distance measurement

Auto Safety

Automatic stop when obstacle detected

Hardware Components Required

All the components needed to build this project

Arduino UNO

Description: The main microcontroller board that runs the code and controls all other components. It processes sensor data and controls the relay.

Specifications:

  • Microcontroller: ATmega328P
  • Operating Voltage: 5V
  • Digital I/O Pins: 14
  • Used Pins: 7, 12, 13
Quantity: 1 Buy Now

Ultrasonic Sensor (HC-SR04)

Description: Measures distance to obstacles using ultrasonic sound waves. Sends and receives signals to calculate distance accurately.

Specifications:

  • Range: 2cm to 400cm
  • Operating Voltage: 5V
  • Trigger Pin: Pin 13
  • Echo Pin: Pin 12
  • Detection Angle: 15°
Quantity: 1 Buy Now

Gear Motor (with Driver)

Description: High-torque DC motors that drive the car wheels. Provides sufficient power for movement and can be controlled via the relay.

Specifications:

  • Voltage: 6V - 12V DC
  • RPM: 100-300
  • Torque: High
  • Shaft: Compatible with wheels
Quantity: 2 Buy Now

Wheels

Description: Durable plastic or rubber wheels that attach to the gear motors. Provides smooth movement and traction.

Specifications:

  • Diameter: 65mm - 70mm
  • Material: Rubber/Plastic
  • Mounting: Compatible with motor shaft
  • Type: 2 powered + 2 free/caster
Quantity: 4

Relay Module

Description: An electronically controlled switch that controls the motor power. Active LOW relay - HIGH signal stops the car, LOW signal allows movement.

Specifications:

  • Type: Single Channel Relay
  • Operating Voltage: 5V
  • Control Pin: Pin 7
  • Load: Up to 10A
  • Trigger: Active LOW
Quantity: 1 Buy Now

Jumper Wires

Description: Male-to-male, male-to-female, and female-to-female wires for making connections between components.

Specifications:

  • Length: 20cm standard
  • Types: M-M, M-F, F-F
  • Colors: Multiple for easy tracking
  • Rating: 24 AWG
Quantity: 10-15 wires Buy Now

Power Switch

Description: ON/OFF toggle switch to control the main power supply to the entire circuit.

Specifications:

  • Type: SPST Toggle Switch
  • Rating: 3A 250V
  • Mounting: Panel mount
  • Operation: ON/OFF
Quantity: 1

9V Battery

Description: Portable power source - one for Arduino and one for motors. Provides independent power supply for stable operation.

Specifications:

  • Voltage: 9V DC
  • Capacity: 500-600mAh
  • Type: PP3 (Alkaline/Rechargeable)
  • Usage: 1 for Arduino, 1 for Motors
Quantity: 2

Arduino Code

Upload this code to your Arduino UNO using the Arduino IDE

How the Code Works:

1. Pin Setup:

Pin 13 (Trigger) and Pin 12 (Echo) for ultrasonic sensor. Pin 7 controls the relay module.

2. Distance Measurement:

Sends ultrasonic pulse and measures echo time. Converts time to distance in centimeters.

3. Decision Logic:

If obstacle detected within 20cm, relay turns HIGH (stops car). Otherwise, relay stays LOW (car moves).

4. Active LOW Relay:

This relay works in reverse - LOW = Motors ON (moving), HIGH = Motors OFF (stopped).

accident_avoiding_car.ino

Upload Instructions:

  1. Connect your Arduino UNO to your computer via USB cable
  2. Open Arduino IDE software
  3. Copy the code above and paste it in the Arduino IDE
  4. Select Tools → Board → Arduino UNO
  5. Select Tools → Port → COM X (your Arduino's port)
  6. Click the Upload button (→ icon)
  7. Wait for "Done uploading" message
  8. Open Tools → Serial Monitor to see distance readings
Important Circuit Notes:
  • Connect ultrasonic sensor VCC to Arduino 5V, GND to GND
  • Trigger pin to Arduino Pin 13, Echo pin to Arduino Pin 12
  • Relay signal pin to Arduino Pin 7, VCC to 5V, GND to GND
  • Connect motors through relay (COM and NO terminals)
  • Use separate power supply for motors (9V battery)
  • Ensure common ground between Arduino and motor power supply

Scan to Visit

Scan this QR code to open the website on your mobile device

QR Code for Accident Avoiding Car Website

accident-avoiding-car.netlify.app