Build Your Own
Overspeed Detector Robot!
Use two IR sensors and an Arduino to catch speeding objects — like a real traffic police system! Perfect for school science fairs and robotics clubs.
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 secondsThen 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.
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!
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!
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.
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.
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.
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!
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.
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!
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!
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 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... "); } }
Speed Calculator Simulator 🎮
Adjust the sliders to see how the speed calculation works — just like the actual Arduino code does it!
Formula used: speed = (distance ÷ time) × 3.6 → result compared to your speed limit
Questions kids often ask ❓
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!
Comments
Post a Comment