Overspeed limit detector

Overspeed Detector Robot Project for Kids | Dual IR Sensor Science Project

How does it work? 🧠

Imagine two finish-line lasers in a race. When a car crosses the first line, a timer starts. When it crosses the second line, the timer stops. From the distance and time, we can calculate speed!

Our robot uses two IR (Infrared) sensors spaced exactly 10 centimetres apart. An object passing in front of them breaks the invisible infrared beam — and our Arduino measures how fast it moved!

📡

IR Sensor 1

Detects the object first and starts the timer

⏱️

Arduino Timer

Measures exact milliseconds between sensor triggers

📡

IR Sensor 2

Detects the object again and stops the timer

🚨

Buzzer + LCD

Alerts you if the speed is too high!

The Speed Formula (don't worry, it's simple!)

Speed = Distance ÷ Time = 0.1 metres ÷ time in seconds

Then multiply by 3.6 to convert m/s into km/h — just like your car's speedometer!

What you need 🛒

All these parts are available at your local electronics shop or online. The total cost is around ₹300–₹500.

1
Arduino UNO
The brain of our robot
2
IR Sensor Modules × 2
The "eyes" that detect objects
3
LCD Display 16×2
Shows speed on screen
4
I2C Module for LCD
Connects LCD with only 2 wires
5
Piezo Buzzer
Beeps when overspeed detected
6
LED (Red)
Warning light for overspeed
7
220Ω Resistor
Protects the LED from burning
8
Breadboard + Jumper Wires
For connecting everything
9
USB Cable
To upload code to Arduino

How to connect everything 🔌

Here's the circuit diagram. Don't panic — it looks complicated but we'll go through each wire one by one!

Overspeed Detector Circuit Diagram ARDUINO UNO D2 ← D3 ← D8 → D9 → A4 → A5 → 5V GND USB IR SENSOR 1 (Left / First) VCC GND OUT IR SENSOR 2 (Right / Second) VCC GND OUT LCD 16×2 + I2C Speed: 45 km/h Status: SAFE SDA → A4 SCL → A5 BUZZER + → D8 – → GND RED LED + → D9 (220Ω) – → GND 10 cm — — — Signal wire IR sensors (green) LCD / I2C (blue)

Pin Connection Table 📌

Component Component Pin Arduino Pin Wire Colour
IR Sensor 1 VCC 5V Red
IR Sensor 1 GND GND Black
IR Sensor 1 OUT D2 Green
IR Sensor 2 VCC 5V Red
IR Sensor 2 GND GND Black
IR Sensor 2 OUT D3 Green
Buzzer + D8 Orange
Buzzer GND Black
Red LED Anode (+) D9 → 220Ω resistor Yellow
Red LED Cathode (–) GND Black
LCD I2C SDA A4 Blue
LCD I2C SCL A5 Blue
LCD I2C VCC 5V Red
LCD I2C GND GND Black

Step-by-step instructions 🔧

Follow these steps carefully. Ask an adult to help with the wiring parts!

1

Set up the breadboard

Place your breadboard on a flat table. Put the Arduino UNO next to it. Connect the Arduino's 5V pin to the red (+) rail on the breadboard, and GND to the blue (–) rail using jumper wires.

💡 Tip: The red rail is your power supply, and the blue rail is your ground (like the negative end of a battery).
2

Place IR Sensor 1 (the starting sensor)

Push IR Sensor 1 onto the breadboard on the LEFT side. Connect VCC to the red power rail, GND to the blue ground rail, and OUT pin to Arduino digital pin D2 using a green jumper wire.

📏 Remember: Both sensors must be exactly 10 cm apart! Use a ruler to measure carefully.
3

Place IR Sensor 2 (the stopping sensor)

Place IR Sensor 2 exactly 10 cm to the RIGHT of Sensor 1. Connect the same way: VCC → 5V, GND → GND, but this time OUT → Arduino pin D3.

🎯 Make sure both sensors face the same direction — they should both point at the area where your object will pass!
4

Connect the buzzer

Place the buzzer on the breadboard. Connect the positive (+) pin to Arduino pin D8, and the negative (–) pin to GND. The buzzer will beep when someone goes too fast!

5

Connect the red LED

Push the LED into the breadboard. Connect the longer leg (anode/+) through a 220Ω resistor to Arduino pin D9. Connect the shorter leg (cathode/–) to GND.

⚠️ Always use a resistor with LEDs! Without it, the LED can burn out instantly.
6

Connect the LCD display

Attach the I2C module to the back of your LCD display (if not already attached). Then connect: SDA → Arduino A4, SCL → Arduino A5, VCC → 5V, GND → GND. That's it — only 4 wires!

7

Upload the code and test!

Connect your Arduino to the computer using the USB cable. Open Arduino IDE, copy the code from the next section, and click Upload. Once done, wave your hand past the sensors and watch the speed appear on the LCD!

🎉 If the LCD shows "0.00 km/h" at the start, that means it's working and waiting for something to pass by!

The code that makes it work 💻

Copy this code into your Arduino IDE. Every important part is explained with green comments (lines starting with //).

overspeed_detector.ino
// ================================================
// OVERSPEED DETECTOR WITH DUAL IR SENSORS
// Made for kids! Built with Arduino UNO
// ================================================

#include <Wire.h>              // For I2C communication
#include <LiquidCrystal_I2C.h>  // For the LCD display

// ---- LCD Setup ----
// Address 0x27 works for most I2C LCD modules
LiquidCrystal_I2C lcd(0x27, 16, 2);

// ---- Pin Numbers ----
const int IR1_PIN = 2;     // IR Sensor 1 → D2
const int IR2_PIN = 3;     // IR Sensor 2 → D3
const int BUZZER  = 8;     // Buzzer → D8
const int LED_PIN = 9;     // Red LED → D9

// ---- Distance between sensors ----
const float DISTANCE = 0.10; // 10 cm = 0.10 metres

// ---- Speed Limit (change this!) ----
const float SPEED_LIMIT = 30.0; // km/h — adjust as needed

// ---- Internal variables ----
unsigned long startTime = 0;
bool sensor1Triggered = false;
bool measuring = false;

// ================================================
// SETUP — runs once when Arduino turns on
// ================================================
void setup() {
  // Set pin modes
  pinMode(IR1_PIN, INPUT);
  pinMode(IR2_PIN, INPUT);
  pinMode(BUZZER,  OUTPUT);
  pinMode(LED_PIN, OUTPUT);

  // Start LCD
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Speed Detector!");
  lcd.setCursor(0, 1);
  lcd.print("Ready...        ");

  // Serial monitor (for debugging)
  Serial.begin(9600);
  Serial.println("Overspeed Detector Ready!");
  delay(2000);
}

// ================================================
// LOOP — runs forever, checking sensors
// ================================================
void loop() {

  // Read both sensors (LOW = object detected!)
  int s1 = digitalRead(IR1_PIN);
  int s2 = digitalRead(IR2_PIN);

  // STEP 1: Sensor 1 detects something → START TIMER
  if (s1 == LOW && !measuring) {
    startTime = millis();   // Record start time
    measuring = true;
    lcd.setCursor(0, 0);
    lcd.print("Detected! ->    ");
    lcd.setCursor(0, 1);
    lcd.print("Timing...       ");
  }

  // STEP 2: Sensor 2 detects it → STOP TIMER & CALCULATE
  if (s2 == LOW && measuring) {
    unsigned long endTime = millis();
    float timeSec = (endTime - startTime) / 1000.0; // ms → seconds

    // Safety check: ignore if too slow (might be noise)
    if (timeSec > 0.01) {
      float speedMS  = DISTANCE / timeSec;         // metres per second
      float speedKMH = speedMS * 3.6;              // convert to km/h

      // Show speed on LCD
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Speed: ");
      lcd.print(speedKMH, 1);
      lcd.print(" km/h");

      // STEP 3: Check if speed is too high
      if (speedKMH > SPEED_LIMIT) {
        lcd.setCursor(0, 1);
        lcd.print("!! OVERSPEED !! ");
        digitalWrite(LED_PIN, HIGH);  // Turn on red LED
        tone(BUZZER, 1000, 1000);      // BEEP for 1 second
        Serial.print("OVERSPEED! Speed: ");
      } else {
        lcd.setCursor(0, 1);
        lcd.print("Status: SAFE :) ");
        digitalWrite(LED_PIN, LOW);   // LED off
        Serial.print("Safe speed: ");
      }

      Serial.println(speedKMH);
      delay(3000);        // Show result for 3 seconds
      digitalWrite(LED_PIN, LOW);
    }

    // Reset for the next object
    measuring = false;
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Speed Detector  ");
    lcd.setCursor(0, 1);
    lcd.print("Ready...        ");
  }
}
📦 Don't forget to install the LiquidCrystal_I2C library! In Arduino IDE go to: Sketch → Include Library → Manage Libraries → search "LiquidCrystal I2C" and install it.

Speed Calculator Simulator 🎮

Adjust the sliders to see how the speed calculation works — just like the actual Arduino code does it!

🔬 Live Speed Calculator
10 cm
100 ms
30 km/h
CALCULATED SPEED
3.6 km/h
✅ SAFE

Formula used: speed = (distance ÷ time) × 3.6 → result compared to your speed limit

Questions kids often ask ❓

Why do we need TWO sensors — why not just one?
One sensor can only detect if something is there or not. But speed needs TWO measurements — where the object WAS, and where it IS now. With two sensors, we know the distance (10 cm) and we measure the time it takes. Speed = Distance ÷ Time. That's the magic formula!
What is an IR sensor and why is it invisible?
IR stands for Infrared. It's a type of light, just like the red, green, and blue light we see — but infrared has a longer wavelength that our eyes can't detect. The sensor sends out invisible IR light and checks if anything is blocking it. When you pass your hand through, the light gets blocked, and the sensor says "Hey! Something's there!"
Can I use this to measure the speed of my toy car?
Absolutely! That's one of the best ways to test it. Make a little track, place both sensors 10 cm apart on the sides, and push your toy car through. The LCD will show the car's speed in km/h. Try pushing harder or softer and see how the number changes!
What happens if the sensors are NOT exactly 10 cm apart?
The speed reading will be wrong! If the actual distance is 12 cm but your code says 10 cm, the Arduino will think the object was slower than it really was. You can change the DISTANCE value in the code to match whatever gap you actually use. Accuracy in measurement = accurate results!
How do real traffic speed cameras work — is it similar?
Yes, very similar! Real speed cameras use radar (radio waves), lidar (laser beams), or sensors embedded in the road. Some use two sensors on the road — just like ours — and calculate speed the same way: Speed = Distance ÷ Time. Our project is a miniature version of the real thing!
Can I change the speed limit in the code?
Yes! Look for this line in the code: const float SPEED_LIMIT = 30.0; — just change 30.0 to any number you want. Set it to 5.0 for testing with slow hand movements, or 50.0 for fast toy cars!

Cool upgrades you can try 🚀

Once your basic project works, try these fun additions!

📊

Data Logger

Save all speed readings to a memory card and analyse them later

📱

Bluetooth Alert

Add an HC-05 module to send alerts to your phone via Bluetooth

🖥️

More Lanes

Add a third and fourth sensor pair to monitor two lanes at once

📷

Camera Module

Take a photo when overspeed is detected — just like a real speed camera!

Overspeed Detector — Robotics Project for Kids

Built with ❤️ for curious young engineers | Great for school science fairs, robotics clubs, and STEM projects

Keywords: Arduino speed detector, dual IR sensor project, kids robotics, overspeed alarm circuit, STEM school project

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course