Wednesday, 2 December 2026

Implementation of a Speed Control and Accident Avoidance Of vehicle using Multi Sensors with Arduino

AUTOMATIC SPEED CONTROL AND ACCIDENT AVOIDANCE SYSTEM USING MULTIPLE SENSORS AND ARDUINO

SCHOOL SCIENCE FAIR – COMPLETE PROJECT DOCUMENTATION

English + తెలుగు | Step-by-Step Explanation | Circuit Diagram | Block Diagram | Flowcharts | Arduino Code | Project Presentation

Arduino Obstacle Avoiding Car using Servo and L298N Driver - Hackster.io

Automatic Vehicle Speed Control System in Public Place | Arduino Road – Harish Projects

Build a 4WD autonomous car with Arduino — codemahal

13

  1. Project title

Recommended professional project title:

Design and Development of an Intelligent Automatic Vehicle Speed Control and Accident Avoidance System Using Multiple Sensors and Arduino

Other suitable titles:

  1. Smart Vehicle Speed Control and Collision Avoidance System Using Arduino and Multi-Sensor Technology.
  2. Arduino-Based Intelligent Automatic Braking and Accident Prevention System.
  3. Multi-Sensor-Based Smart Vehicle Safety and Automatic Speed Regulation System.
  4. Real-Time Obstacle Detection, Automatic Speed Reduction and Emergency Braking System for Vehicles.
  5. Intelligent Road Safety System Using Ultrasonic, IR and Speed Sensors.
  1. Project introduction – English

Road accidents are one of the major problems affecting human life. Many accidents occur because of excessive speed, sudden obstacles, poor visibility, delayed driver reactions and unsafe driving conditions.

This project proposes an intelligent vehicle safety system using an Arduino microcontroller and multiple sensors. The system continuously monitors the surrounding environment and the movement of a model vehicle.

When an obstacle is detected in front of the vehicle, the ultrasonic sensor measures the distance. Based on the detected distance, the Arduino automatically reduces the motor speed or activates the braking mechanism.

An IR sensor can detect nearby obstacles, while a speed sensor monitors the speed of the vehicle. The Arduino processes the sensor information and controls the motor through an L298N motor driver.

The main objective is to demonstrate how multiple sensors can work together to reduce vehicle speed automatically, detect potential collisions and prevent accidents.

Important: This is an educational working prototype for a school science exhibition. It demonstrates safety-assistance principles and must not be connected to or used as an actual road vehicle's braking or acceleration system.

  1. Project objectives
  1. To develop an automatic vehicle speed control system.
  2. To detect obstacles using multiple sensors.
  3. To reduce vehicle speed when an obstacle is detected.
  4. To demonstrate automatic emergency braking.
  5. To monitor vehicle speed using a speed sensor.
  6. To improve awareness of intelligent transportation systems.
  7. To demonstrate the application of Arduino in vehicle safety.
  8. To develop a low-cost prototype suitable for school science fairs.
  1. Working principle

The project works using three main sensing technologies.

Probots AJ-SR04M Waterproof Ultrasonic Sensor | 20cm-8m Range Buy Online India

  1. Ultrasonic sensor (HC-SR04)

Measures the distance between the vehicle and an obstacle in front of it.

IR Infrared Obstacle Avoidance Sensor Module 3-Pin Reflective Photoele – Keszoox

  1. IR obstacle detection sensor

Detects nearby objects and provides an additional obstacle warning.

Optical Slot Speed Sensor

  1. IR speed sensor / encoder

Counts the rotations of the vehicle wheel and calculates its rotational speed.

How the system operates

  1. The vehicle starts moving at normal speed.
  2. The ultrasonic sensor continuously measures the distance ahead.
  3. The IR obstacle sensor checks for nearby objects.
  4. The speed sensor measures wheel rotation.
  5. Arduino analyses the readings.
  6. If an obstacle is far away, the vehicle continues at normal speed.
  7. If an obstacle approaches, the Arduino reduces the motor speed.
  8. If the obstacle is very close, the motor stops automatically.
  9. The buzzer and warning LED alert the user.
  10. When the obstacle is removed, the system can resume operation.
  1. Required components and materials

No.

Component

Quantity

Purpose

1

Arduino UNO

1

Main controller

2

HC-SR04 ultrasonic sensor

1

Distance measurement

3

IR obstacle sensor

1

Obstacle detection

4

IR encoder/speed sensor

1

Wheel speed measurement

5

L298N motor driver

1

Motor speed control

6

DC geared motors

2

Vehicle movement

7

Robot car chassis with wheels

1

Vehicle body

8

Buzzer

1

Sound alert

9

Red LED

1

Warning indication

10

Green LED

1

Normal operation indication

11

220-ohm resistors

2

LED protection

12

Battery pack suitable for motors

1

Motor power

13

USB cable

1

Arduino programming

14

Jumper wires

As needed

Connections

15

Breadboard

1

Circuit assembly

Choosing an Arduino for Your Project

HC-SR04 Ultrasonic Module Distance Sensor | Ultrasonic Distance Sensor | Rapid Robotics Australia

Driver Motor Ponte H L298N - Bit Maker - Arduino, Robótica e Componentes Eletrônicos

8

Estimated project cost

Indicative Indian educational-prototype prices; actual prices vary by supplier.

Component group

Estimated cost

Arduino UNO compatible board

₹350–₹600

Sensors (3)

₹180–₹350

L298N motor driver

₹100–₹180

Motors and chassis

₹300–₹500

Battery and holder

₹150–₹250

LEDs, buzzer, resistors, wires

₹100–₹200

Total

₹1,180–₹2,080

  1. Block diagram

MULTI-SENSOR INPUT UNIT

HC-SR04 + IR Obstacle Sensor + IR Speed Sensor

ARDUINO UNO

Sensor data processing and decision-making

MOTOR DRIVER – L298N

Automatic PWM speed regulation and motor stopping

VEHICLE MOVEMENT

Normal speed / Reduced speed / Stop

WARNING INDICATION

Buzzer + Red LED + Green LED

  1. Circuit connections – Arduino UNO

Use the following pin configuration.

Component

Sensor/module pin

Arduino connection

HC-SR04

VCC

5V

HC-SR04

GND

GND

HC-SR04

TRIG

D9

HC-SR04

ECHO

D10

IR obstacle sensor

VCC

5V

IR obstacle sensor

GND

GND

IR obstacle sensor

OUT

D4

IR speed sensor

VCC

5V

IR speed sensor

GND

GND

IR speed sensor

OUT

D2

L298N

ENA

D5 (PWM)

L298N

IN1

D7

L298N

IN2

D8

Buzzer

Positive

D12

Buzzer

Negative

GND

Red LED

Anode through 220Ω

D11

Green LED

Anode through 220Ω

D13

LEDs

Cathode

GND

L298N motor connections:

  • OUT1 and OUT2: Left DC motor.
  • OUT3 and OUT4: Right DC motor.
  • Motor battery positive: L298N motor supply terminal.
  • Motor battery negative: L298N GND.
  • Arduino GND: L298N GND.

For this demonstration, both motors receive the same speed command. The encoder should be attached to the wheel or motor being monitored.

Autonomous Robot for Hospital Application

ijraset.com

Important wiring precautions

  1. Remove the ENA jumper on the L298N if you are controlling ENA with Arduino PWM on D5.
  2. Do not connect the motors directly to Arduino output pins.
  3. Use a suitable separate motor battery supply.
  4. Connect Arduino, sensor and motor-driver grounds together.
  5. Check the motor driver's voltage and current ratings.
  6. Do not power the motors from the Arduino 5V pin.
  7. If using a 9V rectangular PP3 battery, it may not supply sufficient current for the motors. Use a suitable rechargeable battery pack instead.
  1. Automatic speed control logic

The system changes motor speed according to the distance detected by the ultrasonic sensor.

Obstacle distance

Vehicle action

Motor PWM

Alert

Above 50 cm

Normal movement

180

Green LED

26–50 cm

Reduce speed

120

Warning

11–25 cm

Very slow movement

70

Buzzer

10 cm or less

Emergency stop

0

Red LED + buzzer

IR sensor detects obstacle

Emergency stop

0

Red LED + buzzer

PWM values range from 0 (stop) to 255 (maximum command). Actual vehicle speed depends on the motor, battery, load and chassis.

Example:

If the vehicle detects an obstacle at 80 cm, it continues at normal speed.

If the obstacle comes to 40 cm, the vehicle reduces its speed.

If the obstacle comes to 20 cm, it moves very slowly.

If the obstacle reaches 8 cm, the Arduino stops the motors and activates the warning system.

  1. Flowchart

#chatgpt-mermaid-_r_t2_{font-family:-apple-system-body,ui-sans-serif,-apple-system,system-ui,"Segoe UI",Helvetica,"Apple Color Emoji",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;fill:rgb(13, 13, 13);}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#chatgpt-mermaid-_r_t2_ .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#chatgpt-mermaid-_r_t2_ .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#chatgpt-mermaid-_r_t2_ .error-icon{fill:rgb(243, 243, 243);}#chatgpt-mermaid-_r_t2_ .error-text{fill:rgb(13, 13, 13);stroke:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ .edge-thickness-normal{stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .edge-thickness-thick{stroke-width:3.5px;}#chatgpt-mermaid-_r_t2_ .edge-pattern-solid{stroke-dasharray:0;}#chatgpt-mermaid-_r_t2_ .edge-thickness-invisible{stroke-width:0;fill:none;}#chatgpt-mermaid-_r_t2_ .edge-pattern-dashed{stroke-dasharray:3;}#chatgpt-mermaid-_r_t2_ .edge-pattern-dotted{stroke-dasharray:2;}#chatgpt-mermaid-_r_t2_ .marker{fill:rgb(143, 143, 143);stroke:rgb(143, 143, 143);}#chatgpt-mermaid-_r_t2_ .marker.cross{stroke:rgb(143, 143, 143);}#chatgpt-mermaid-_r_t2_ svg{font-family:-apple-system-body,ui-sans-serif,-apple-system,system-ui,"Segoe UI",Helvetica,"Apple Color Emoji",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:16px;}#chatgpt-mermaid-_r_t2_ p{margin:0;}#chatgpt-mermaid-_r_t2_ .label{font-family:-apple-system-body,ui-sans-serif,-apple-system,system-ui,"Segoe UI",Helvetica,"Apple Color Emoji",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";color:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ .cluster-label text{fill:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ .cluster-label span{color:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ .cluster-label span p{background-color:transparent;}#chatgpt-mermaid-_r_t2_ .label text,#chatgpt-mermaid-_r_t2_ span{fill:rgb(13, 13, 13);color:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ .node rect,#chatgpt-mermaid-_r_t2_ .node circle,#chatgpt-mermaid-_r_t2_ .node ellipse,#chatgpt-mermaid-_r_t2_ .node polygon,#chatgpt-mermaid-_r_t2_ .node path{fill:rgb(222, 234, 251);stroke:rgb(83, 154, 248);stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .rough-node .label text,#chatgpt-mermaid-_r_t2_ .node .label text,#chatgpt-mermaid-_r_t2_ .image-shape .label,#chatgpt-mermaid-_r_t2_ .icon-shape .label{text-anchor:middle;}#chatgpt-mermaid-_r_t2_ .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .rough-node .label,#chatgpt-mermaid-_r_t2_ .node .label,#chatgpt-mermaid-_r_t2_ .image-shape .label,#chatgpt-mermaid-_r_t2_ .icon-shape .label{text-align:center;}#chatgpt-mermaid-_r_t2_ .node.clickable{cursor:pointer;}#chatgpt-mermaid-_r_t2_ .root .anchor path{fill:rgb(143, 143, 143)!important;stroke-width:0;stroke:rgb(143, 143, 143);}#chatgpt-mermaid-_r_t2_ .arrowheadPath{fill:rgb(143, 143, 143);}#chatgpt-mermaid-_r_t2_ .edgePath .path{stroke:rgb(143, 143, 143);stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .flowchart-link{stroke:rgb(143, 143, 143);fill:none;}#chatgpt-mermaid-_r_t2_ .edgeLabel{background-color:rgb(252, 252, 252);text-align:center;}#chatgpt-mermaid-_r_t2_ .edgeLabel p{background-color:rgb(252, 252, 252);}#chatgpt-mermaid-_r_t2_ .edgeLabel rect{opacity:0.5;background-color:rgb(252, 252, 252);fill:rgb(252, 252, 252);}#chatgpt-mermaid-_r_t2_ .labelBkg{background-color:rgba(252, 252, 252, 0.5);}#chatgpt-mermaid-_r_t2_ .cluster rect{fill:rgb(243, 243, 243);stroke:rgba(0, 0, 0, 0.1);stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .cluster text{fill:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ .cluster span{color:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:-apple-system-body,ui-sans-serif,-apple-system,system-ui,"Segoe UI",Helvetica,"Apple Color Emoji",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";font-size:12px;background:rgb(243, 243, 243);border:1px solid rgba(0, 0, 0, 0.1);border-radius:2px;pointer-events:none;z-index:100;}#chatgpt-mermaid-_r_t2_ .flowchartTitleText{text-anchor:middle;font-size:18px;fill:rgb(13, 13, 13);}#chatgpt-mermaid-_r_t2_ rect.text{fill:none;stroke-width:0;}#chatgpt-mermaid-_r_t2_ .icon-shape,#chatgpt-mermaid-_r_t2_ .image-shape{background-color:rgb(252, 252, 252);text-align:center;}#chatgpt-mermaid-_r_t2_ .icon-shape p,#chatgpt-mermaid-_r_t2_ .image-shape p{background-color:rgb(252, 252, 252);padding:2px;}#chatgpt-mermaid-_r_t2_ .icon-shape .label rect,#chatgpt-mermaid-_r_t2_ .image-shape .label rect{opacity:0.5;background-color:rgb(252, 252, 252);fill:rgb(252, 252, 252);}#chatgpt-mermaid-_r_t2_ .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#chatgpt-mermaid-_r_t2_ .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#chatgpt-mermaid-_r_t2_ .node .neo-node{stroke:rgb(83, 154, 248);}#chatgpt-mermaid-_r_t2_ [data-look="neo"].node rect,#chatgpt-mermaid-_r_t2_ [data-look="neo"].cluster rect,#chatgpt-mermaid-_r_t2_ [data-look="neo"].node polygon{stroke:url(#chatgpt-mermaid-_r_t2_-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#chatgpt-mermaid-_r_t2_ [data-look="neo"].swimlane.cluster rect{filter:none;}#chatgpt-mermaid-_r_t2_ [data-look="neo"].node path{stroke:url(#chatgpt-mermaid-_r_t2_-gradient);stroke-width:1px;}#chatgpt-mermaid-_r_t2_ [data-look="neo"].node .outer-path{filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#chatgpt-mermaid-_r_t2_ [data-look="neo"].node .neo-line path{stroke:rgb(83, 154, 248);filter:none;}#chatgpt-mermaid-_r_t2_ [data-look="neo"].node circle{stroke:url(#chatgpt-mermaid-_r_t2_-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#chatgpt-mermaid-_r_t2_ [data-look="neo"].node circle .state-start{fill:#000000;}#chatgpt-mermaid-_r_t2_ [data-look="neo"].icon-shape .icon{fill:url(#chatgpt-mermaid-_r_t2_-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#chatgpt-mermaid-_r_t2_ [data-look="neo"].icon-shape .icon-neo path{stroke:url(#chatgpt-mermaid-_r_t2_-gradient);filter:drop-shadow( 1px 2px 2px rgba(185,185,185,1));}#chatgpt-mermaid-_r_t2_ .node text{font-size:14px;font-weight:600;letter-spacing:normal;fill:rgb(0, 79, 153);}#chatgpt-mermaid-_r_t2_ .edgeLabels text{font-size:13px;font-weight:600;letter-spacing:-0.08px;fill:rgb(0, 79, 153);}#chatgpt-mermaid-_r_t2_ .node tspan[font-weight="normal"],#chatgpt-mermaid-_r_t2_ .edgeLabels tspan[font-weight="normal"]{font-weight:600;}#chatgpt-mermaid-_r_t2_ .edgeLabel .label rect{opacity:1;rx:13px;ry:13px;fill:rgb(245, 250, 255);stroke:rgb(206, 219, 229);stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .node rect,#chatgpt-mermaid-_r_t2_ .node circle,#chatgpt-mermaid-_r_t2_ .node ellipse,#chatgpt-mermaid-_r_t2_ .node polygon,#chatgpt-mermaid-_r_t2_ .node path{fill:rgb(229, 243, 255);stroke:rgba(0, 0, 0, 0.1);stroke-width:1px;}#chatgpt-mermaid-_r_t2_ .node rect{rx:16px;ry:16px;}#chatgpt-mermaid-_r_t2_ .mermaid-decision .label-container{fill:rgb(245, 250, 255);stroke:rgb(206, 219, 229);stroke-dasharray:2,2;}#chatgpt-mermaid-_r_t2_ .edgePaths .flowchart-link{stroke:rgb(143, 143, 143);stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;}#chatgpt-mermaid-_r_t2_ .marker{fill:rgb(143, 143, 143);stroke:rgb(143, 143, 143);}#chatgpt-mermaid-_r_t2_ :root{--mermaid-font-family:-apple-system-body,ui-sans-serif,-apple-system,system-ui,"Segoe UI",Helvetica,"Apple Color Emoji",Arial,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";}STARTPower ON ArduinoInitialize Sensors and MotorDriverStart VehicleMeasure Obstacle DistanceRead IR Obstacle SensorMeasure Wheel SpeedIR Obstacle Detected?Stop Motor and Activate AlarmDistance <= 10 cm?Distance <= 25 cm?Very Slow SpeedDistance <= 50 cm?Reduce SpeedNormal SpeedUpdate Warning IndicatorsYesNoYesNoYesNoYesNo

  1. Step-by-step construction procedure

Step 1: Prepare the vehicle chassis

ateliers:robot_arduino [DokuWiki du LOV]

labovilleurbanne.fr

  • Take the robot car chassis.
  • Fix two DC geared motors.
  • Attach the wheels.
  • Install the front caster wheel if your chassis has one.
  • Secure the Arduino board and motor driver.

Step 2: Install the ultrasonic sensor

4WD SMART ROBOT CAR : 16 Steps - Instructables

instructables.com

  • Place the HC-SR04 sensor at the front of the vehicle.
  • Make sure both ultrasonic transducers face forward.
  • Connect VCC, GND, TRIG and ECHO.

Step 3: Install the IR obstacle sensor

Robô Seguidor de Linha - Tutorial Completo - Blog Eletrogate

blog.eletrogate.com

  • Mount the IR obstacle sensor near the front.
  • Connect its output to Arduino D4.
  • Adjust the onboard potentiometer to set detection sensitivity.
  • Check whether the sensor output becomes LOW or HIGH when an obstacle is detected. The code below assumes LOW.

Step 4: Install the speed sensor

Reviews: BO motor + Wheel + Encoder Disc + Encoder sensor Combo BO motor + Wheel + Encoder Disc + Encoder sensor Combo [RKI-2655] - ₹260.00 : Robokits India, Easy to use, Versatile Robotics & DIY kits

robokits.co.in

  • Mount the encoder sensor near one wheel.
  • Attach a slotted encoder disc or suitable rotating target.
  • Align the sensor with the rotating disc.
  • Connect its signal output to D2.
  • Count pulses to calculate the wheel's RPM.

Step 5: Connect the motor driver

  • Connect both motors to the L298N output terminals.
  • Connect the Arduino control pins.
  • Connect the separate motor battery.
  • Ensure all grounds are common.

Step 6: Install the warning system

  • Connect the red LED to D11 through a 220-ohm resistor.
  • Connect the green LED to D13 through a 220-ohm resistor.
  • Connect the buzzer to D12 and GND.

Step 7: Upload the program

  • Open Arduino IDE.
  • Select Arduino UNO.
  • Select the correct COM port.
  • Paste the program below.
  • Compile and upload the program.

Step 8: Test the vehicle

  • Switch ON the power.
  • Place an object 80 cm in front of the vehicle.
  • Observe normal movement.
  • Move the object to 40 cm.
  • Observe speed reduction.
  • Move the object to 20 cm.
  • Observe very slow movement.
  • Move the object to 8 cm.
  • Verify that the vehicle stops and the buzzer sounds.
  1. Complete Arduino source code

The following program is designed for the pin connections given above. It includes:

  • Ultrasonic distance measurement.
  • IR obstacle detection.
  • Wheel speed measurement.
  • Automatic speed reduction.
  • Automatic motor stopping.
  • Buzzer warning.
  • Red and green LED indications.
  • Serial Monitor output.

 

/*

  PROJECT:

  Automatic Vehicle Speed Control and

  Accident Avoidance Using Multiple Sensors

 

  Controller: Arduino UNO

  Sensors:

  1. HC-SR04 Ultrasonic Sensor
  2. IR Obstacle Sensor
  3. IR Wheel Speed Encoder

 

  Motor Driver: L298N

*/

 

// -------- PIN CONFIGURATION --------

 

// Ultrasonic Sensor

const int TRIG_PIN = 9;

const int ECHO_PIN = 10;

 

// IR Obstacle Sensor

const int IR_OBSTACLE = 4;

 

// IR Speed Sensor

const int SPEED_SENSOR = 2;

 

// L298N Motor Driver

const int ENA = 5;     // PWM

const int IN1 = 7;

const int IN2 = 8;

 

// Warning System

const int BUZZER = 12;

const int RED_LED = 11;

const int GREEN_LED = 13;

 

// -------- SETTINGS --------

 

const int NORMAL_SPEED = 180;

const int MEDIUM_SPEED = 120;

const int LOW_SPEED = 70;

 

const int STOP_DISTANCE = 10;

const int LOW_DISTANCE = 25;

const int MEDIUM_DISTANCE = 50;

 

// Set this to the actual number of encoder

// pulses generated per wheel revolution.

const int PULSES_PER_REVOLUTION = 20;

 

// -------- VARIABLES --------

 

volatile unsigned long pulseCount = 0;

 

unsigned long previousTime = 0;

const unsigned long interval = 500;

 

float rpm = 0;

float distance = 999;

 

int motorSpeed = 0;

 

bool obstacleDetected = false;

 

// -------- SPEED SENSOR INTERRUPT --------

 

void countPulse() {

  pulseCount++;

}

 

// -------- ULTRASONIC FUNCTION --------

 

float getDistance() {

 

  digitalWrite(TRIG_PIN, LOW);

  delayMicroseconds(2);

 

  digitalWrite(TRIG_PIN, HIGH);

  delayMicroseconds(10);

 

  digitalWrite(TRIG_PIN, LOW);

 

  unsigned long duration =

      pulseIn(ECHO_PIN, HIGH, 25000UL);

 

  if (duration == 0) {

    return 999;

  }

 

  float cm = duration * 0.0343 / 2.0;

 

  return cm;

}

 

// -------- MOTOR CONTROL --------

 

void moveVehicle(int speedValue) {

 

  speedValue = constrain(speedValue, 0, 255);

 

  digitalWrite(IN1, HIGH);

  digitalWrite(IN2, LOW);

 

  analogWrite(ENA, speedValue);

 

  motorSpeed = speedValue;

}

 

// -------- MOTOR STOP --------

 

void stopVehicle() {

 

  analogWrite(ENA, 0);

 

  digitalWrite(IN1, LOW);

  digitalWrite(IN2, LOW);

 

  motorSpeed = 0;

}

 

// -------- SPEED CALCULATION --------

 

void calculateRPM() {

 

  unsigned long currentTime = millis();

 

  if (currentTime - previousTime >= interval) {

 

    unsigned long count;

 

    noInterrupts();

    count = pulseCount;

    pulseCount = 0;

    interrupts();

 

    float seconds =

        (currentTime - previousTime) / 1000.0;

 

    rpm = (count * 60.0) /

          (PULSES_PER_REVOLUTION * seconds);

 

    previousTime = currentTime;

  }

}

 

// -------- WARNING SYSTEM --------

 

void warningOn() {

 

  digitalWrite(RED_LED, HIGH);

  digitalWrite(GREEN_LED, LOW);

 

  tone(BUZZER, 1000);

}

 

void warningOff() {

 

  digitalWrite(RED_LED, LOW);

  digitalWrite(GREEN_LED, HIGH);

 

  noTone(BUZZER);

}

 

// -------- SETUP --------

 

void setup() {

 

  Serial.begin(9600);

 

  pinMode(TRIG_PIN, OUTPUT);

  pinMode(ECHO_PIN, INPUT);

 

  pinMode(IR_OBSTACLE, INPUT);

  pinMode(SPEED_SENSOR, INPUT);

 

  pinMode(ENA, OUTPUT);

  pinMode(IN1, OUTPUT);

  pinMode(IN2, OUTPUT);

 

  pinMode(BUZZER, OUTPUT);

  pinMode(RED_LED, OUTPUT);

  pinMode(GREEN_LED, OUTPUT);

 

  attachInterrupt(

    digitalPinToInterrupt(SPEED_SENSOR),

    countPulse,

    FALLING

  );

 

  stopVehicle();

 

  previousTime = millis();

 

  Serial.println("SMART VEHICLE SAFETY SYSTEM");

  Serial.println("---------------------------");

 

  warningOff();

}

 

// -------- MAIN PROGRAM --------

 

void loop() {

 

  // Read all sensors

 

  distance = getDistance();

 

  // Assumes IR sensor output LOW

  // when an obstacle is detected.

  obstacleDetected =

      (digitalRead(IR_OBSTACLE) == LOW);

 

  calculateRPM();

 

  // Display sensor information

 

  Serial.print("Distance: ");

  Serial.print(distance);

  Serial.print(" cm");

 

  Serial.print(" | Wheel RPM: ");

  Serial.print(rpm);

 

  Serial.print(" | IR: ");

  Serial.print(obstacleDetected ? "OBSTACLE" : "CLEAR");

 

  // -------- DECISION MAKING --------

 

  if (obstacleDetected ||

      distance <= STOP_DISTANCE) {

 

    stopVehicle();

    warningOn();

 

    Serial.println(" | EMERGENCY STOP");

  }

 

  else if (distance <= LOW_DISTANCE) {

 

    moveVehicle(LOW_SPEED);

    warningOn();

 

    Serial.println(" | VERY LOW SPEED");

  }

 

  else if (distance <= MEDIUM_DISTANCE) {

 

    moveVehicle(MEDIUM_SPEED);

    warningOff();

 

    Serial.println(" | SPEED REDUCED");

  }

 

  else {

 

    moveVehicle(NORMAL_SPEED);

    warningOff();

 

    Serial.println(" | NORMAL SPEED");

  }

 

  delay(50);

}

Important code adjustments:

  1. The IR obstacle sensor is assumed to produce LOW when it detects an object. If your module produces HIGH, change the condition accordingly.
  2. Change PULSES_PER_REVOLUTION to match your encoder's actual pulses per wheel revolution.
  3. The RPM value is measured and displayed; this basic version uses distance thresholds for motor control rather than a calibrated road-speed measurement.
  4. The emergency stop is an electrical motor stop, not a mechanical braking system. The vehicle may coast depending on its momentum and driver circuit.
  1. Expected output and testing results

The following table is an example of expected demonstration behaviour, not measured experimental data.

Test

Distance

Expected motor behaviour

Warning

1

100 cm

Normal speed

Green LED

2

60 cm

Normal speed

Green LED

3

40 cm

Reduced speed

No buzzer

4

20 cm

Very low speed

Buzzer

5

8 cm

Motor stops

Red LED + buzzer

6

IR obstacle detected

Motor stops

Red LED + buzzer

7

Obstacle removed

Resumes based on distance

Normal status

  1. Graphs and charts for science fair

You can use this chart in your project report to explain the relationship between obstacle distance and motor PWM.

Obstacle distance vs motor PWM

Illustrative control settings for the demonstration model.

0 / 25563.75 / 255127.5 / 255191.25 / 255255 / 2558 cm20 cm40 cm60 cm100 cm

Sensor input and output relationship

Sensor input

Arduino decision

Output

No obstacle nearby

Continue

Normal motor speed

Obstacle detected at medium range

Reduce PWM

Slower motor

Obstacle detected at close range

Reduce PWM further

Very slow motor

Critical obstacle distance

Emergency stop

Motor OFF

IR sensor detects obstacle

Emergency stop

Buzzer + red LED

  1. Advantages of the project
  1. Automatic obstacle detection.
  2. Demonstrates intelligent speed regulation.
  3. Multiple sensors provide different types of information.
  4. Reduces the chance of collision in the demonstration environment.
  5. Provides audio and visual warnings.
  6. Low-cost educational prototype.
  7. Easy to demonstrate and understand.
  8. Can be expanded with additional sensors and communication technologies.
  1. Limitations
  1. Ultrasonic sensors may give inaccurate readings on soft, angled or irregular surfaces.
  2. IR sensors can be affected by sunlight and surface reflectivity.
  3. The prototype has limited detection range.
  4. The motor stopping distance depends on speed, weight and surface friction.
  5. The basic program does not identify pedestrians, animals or vehicles.
  6. The encoder measures wheel RPM, not calibrated road speed.
  7. The prototype is not certified for actual vehicle safety applications.
  1. Future enhancements

Technology

Proposed improvement

GPS

Location tracking

GSM module

Emergency SMS

ESP32

Wireless monitoring

Camera

Object recognition

AI / Machine Learning

Intelligent obstacle classification

Rain sensor

Wet-road condition detection

Alcohol sensor

Driver alcohol detection demonstration

OLED display

Distance, RPM and system status

RFID

Speed-zone identification

IoT dashboard

Remote vehicle monitoring

  1. Project abstract

Abstract (English)

The proposed project presents an Arduino-based intelligent vehicle speed control and accident avoidance system using multiple sensors. The system integrates an ultrasonic sensor, IR obstacle detection sensor and wheel speed encoder to monitor obstacles and vehicle movement. The Arduino microcontroller processes sensor information and controls the DC motors through an L298N motor driver.

When an obstacle is detected within a predefined distance, the system automatically reduces the motor speed. When the obstacle reaches a critical distance, the motor is stopped and an audio-visual warning is activated. The wheel encoder measures rotational speed and displays RPM through the Serial Monitor.

The prototype demonstrates the practical application of embedded systems, sensor integration and automatic control techniques for improving road safety.

Keywords: Arduino UNO, Automatic Speed Control, Accident Avoidance, Ultrasonic Sensor, IR Sensor, Speed Monitoring, Automatic Braking, Embedded Systems.