DIY Arduino Speed Detector: Complete Project Guide
Category: Robo cs / DIY Electronics / School Science Project
Difficulty: Beginner to Intermediate
Updated: 2026 Edi on
1. Project Overview
This project uses an Arduino UNO and two IR (Infrared) Sensors to calculate the speed of a moving
object (like a toy car). When the object passes the first sensor, a mer starts; when it passes the
second, the mer stops. Speed is then calculated using the formula:
$$Speed = \frac{Distance}{Time}$$
2. Components Required
Arduino UNO R3 or R4
IR Sensor Modules (2 units)
16x2 LCD Display (with I2C module for easier wiring)
Breadboard and Jumper Wires
9V Ba ery (for portable power)
3. Circuit Connec ons
Follow this pin mapping to set up your hardware:
Component Arduino Pin
IR Sensor 1 (Start) Digital Pin 2
IR Sensor 2 (Stop) Digital Pin 3
LCD SCL Pin A5
LCD SDA Pin A4
VCC (All) 5V
GND (All) GND
4. The Arduino Code
Copy and paste this code into your Arduino IDE.
C++
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27
int sensor1 = 2;
int sensor2 = 3;
unsigned long t1 = 0;
unsigned long t2 = 0;
float velocity;
float distance = 0.20; // Distance between sensors in meters (20cm)
void setup() {
pinMode(sensor1, INPUT);
pinMode(sensor2, INPUT);
[Link]();
[Link]();
[Link]("Speed Detector");
delay(2000);
[Link]();
void loop() {
if (digitalRead(sensor1) == LOW && t1 == 0) {
t1 = millis();
[Link]("Object Detected...");
if (digitalRead(sensor2) == LOW && t1 != 0) {
t2 = millis();
float meTaken = (t2 - t1) / 1000.0; // Convert to seconds
velocity = distance / meTaken; // m/s
[Link]();
[Link](0, 0);
[Link]("Speed: ");
[Link](velocity);
[Link](" m/s");
delay(5000); // Wait 5 seconds before next reading
t1 = 0; t2 = 0; // Reset
[Link]();
5. Step-by-Step Assembly
1. Mount the Sensors: Place the two IR sensors on a flat track. Measure the distance between
them accurately (e.g., 20cm) and update the distance variable in the code.
2. Calibrate: Use the small poten ometer (screw) on the IR sensors to adjust sensi vity so they
only trigger when an object passes directly in front.
3. Upload: Connect your Arduino to your PC, select "Arduino Uno" in the IDE, and hit Upload.
6. How to Present This for a Project
If you are submi ng this for a school grade, include these points:
Real-world Applica on: Traffic police use similar LIDAR/RADAR technology to catch speeding
vehicles.
Future Scope: This can be upgraded to include an SD card module to log data or a camera to
take pictures of "speeding" objects.