DIY vehicle speed radar using Arduino and HC-SR04 sensor

Arduino 16-04-26
13 0

Tutorial plan

1- Objective of the project

2- Required Components

3- Circuit Connections of system

4- Arduino program

 

 

Objective of the project

The objective of this project is to design and build a low-cost vehicle speed radar system using an Arduino UNO. By using two HC-SR04 ultrasonic sensors, the system measures the speed of a moving vehicle over a known distance.

The measured speed is then displayed in real time on an I2C LCD screen. Additionally, a buzzer is used to provide an audible alert when the detected speed exceeds a predefined safety limit.

This project demonstrates the practical application of distance measurement, time calculation, and embedded system control in traffic monitoring.

Functioning:

The system operates by placing two HC-SR04 sensors at a fixed and known distance from each other. When a vehicle passes in front of the first sensor, the Arduino detects its presence and starts a timer.

As the vehicle continues moving and reaches the second sensor, the Arduino stops the timer. Using the recorded time and the known distance between the sensors, the speed is calculated using the basic formula:

Speed = Distance / Time​

The calculated speed is then displayed on the LCD I2C screen in an easy-to-read format. If the speed exceeds a predefined threshold, the buzzer is activated to alert the user.

This setup allows real-time monitoring of vehicle speed in a simple, efficient, and cost-effective way.

 

Required Components

1. Arduino UNO

Arduino Uno

The Arduino UNO is the main control unit of the system. It processes data received from the ultrasonic sensors, calculates the vehicle speed, and controls the LCD display and buzzer. It is based on the ATmega328P microcontroller and is easy to program using the Arduino IDE.

2. HC-SR04 sensor

HC-SR04

These sensors are used to detect the presence of a vehicle and measure distance. Each HC-SR04 works by sending ultrasonic waves and measuring the time it takes for the echo to return. In this project, two sensors are placed a fixed distance apart to calculate the time taken by a vehicle to travel between them.

3- Buzzer :

The buzzer provides an audible alert when the vehicle speed exceeds a predefined limit. It helps in making the system more interactive and useful for warning purposes.

4. LCD Display with I2C Module

The I2C LCD screen is used to display real-time information such as the measured speed, system status, and warning messages.

5. Breadboard 

Breadboard

A breadboard is used to assemble the circuit without soldering. It makes it easy to connect and modify the components during testing and development.

6. Jumper Wires

Jumper wires

Jumper wires are used to connect all the components together on the Arduino and breadboard. They ensure proper electrical connections between sensors, display, and other modules.

 

Circuit Connections of system

1- Connecting the first HC-SR04 sensor to the Arduino UNO

HC-SR04 Arduino UNO
VCC 3 V
Trig D2
Echo D3
GND GND

 

2- Connecting the second HC-SR04 sensor to the Arduino UNO

HC-SR04 Arduino UNO
VCC 3 V
Trig D4
Echo D5
GND GND

 

3- Connecting the Buzzer to the Arduino UNO

Buzzer Arduino UNO
 (+) Terminal D6
(-) Terminal GND

 

4- Connection of LCD I2C display to Arduino UNO

LCD I2C display Arduino UNO
VCC 5V of GPIO card
GND GND
SDA A4
SCL A5

 

Arduino program:

This program implements a vehicle speed radar system using an Arduino UNO, two HC-SR04 Ultrasonic Sensor sensors, an I2C LCD Display, and a Buzzer. Its main purpose is to measure the speed of a moving object (such as a vehicle) and alert the user if the speed exceeds a predefined limit.

You need to install this libraries : LiquidCrystal_I2C for I2C LCD screen

The program begins by configuring system parameters such as the distance between the two sensors, the detection threshold, and the maximum allowed speed. It also defines the pins used to connect the sensors and the buzzer. The LCD is initialized to display system messages and results.

The core of the system relies on ultrasonic distance measurement. A dedicated function sends a signal from each sensor and calculates the distance based on the time taken for the echo to return. Another function uses this distance to determine whether an object is detected within a short range.

During execution, the system continuously waits for an object to pass in front of the first sensor. Once detected, the program records the time using the Arduino’s microsecond timer. It then waits for the object to reach the second sensor and records a second timestamp. The time difference between these two events is used to calculate the speed of the object using the known distance between the sensors.

The calculated speed is displayed on the LCD screen along with the predefined speed limit and the system status. If the measured speed exceeds the limit, the buzzer is activated repeatedly and the display shows an “OVER” warning. Otherwise, the system indicates that the speed is acceptable (“OK”) and emits a short beep.

If an error occurs, such as an invalid time measurement, the program displays an error message on the screen. After each measurement cycle, the system pauses briefly before restarting and waiting for the next object.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

Pictures of the articles

Robotic site created by Mohamed Ali Haj Salah - Teacher info