Project tutorial
Arduino speed detector

Arduino speed detector

Super easy project using an arduino uno to detect speed of various moving objects with the help of a pair of IR sensors and get the speed.

  • 2,242 views
  • 1 comment
  • 9 respects

Components and supplies

Apps and online services

About this project

  • IR sensor based speed detection project.
  • This super easy project is about knowing the speeds of all those small objects such as toy cars etc. whose speeds are difficult to measure and get its speed reading in the serial monitor on your PC.

This project is a must try for those who want to learn the basics of arduino and are looking for a project that boosts confidence and offers hours of joy in a sitting. Enjoy!!!.would love to hear from them who tried this project.

Code

speed_detection101Arduino
here's the code for the speed detector.just upload to arduino after doing the circuitry. sen1 is the first sensors .sen2 is the second.led pin is the pin to the RGB led.The seperation between my sensors was 7.5 cms. you can adjust the speedconst variable for the same.
//code by YaSh.

int sen1=A0;
int sen2=A3;
int ledPin=9;
unsigned long t1=0;
unsigned long t2=0; 
float velocity;
float velocity_real;
float timeFirst;
float timeScnd;
float diff;
float speedConst=7.5;  //in cm.
void setup()
{
  Serial.begin(9600);
  pinMode(sen1,INPUT);
  pinMode(sen2,INPUT);
  analogWrite(11,LOW);
  analogWrite(10,HIGH);
}
  void loop()
  {
    if (analogRead(sen1)<500 && analogRead(sen2)>500)
    {
      timeFirst = millis();
      digitalWrite(ledPin, LOW);
      delay(30);
    }
 
  if (analogRead(sen2)>500 && analogRead(sen1)<500)
  {
    timeScnd = millis();
    diff = timeScnd - timeFirst; 
    velocity = speedConst / diff;
    velocity_real = (velocity*360)/100;     //milliseconds to hours and centimetres to kilometeres.
    delay(30);
    digitalWrite(ledPin, HIGH);
  Serial.print("\n the velocity is : ");
  Serial.println(velocity_real);
  Serial.print(" km/hr. ");
  delay(500);
  digitalWrite(ledPin,LOW);
  delay(500);
  }
  /*else if(analogRead(sen2)<500 && analogRead(sen1)<500)       //uncomment if you want to write it.
  {
      Serial.print("\n Error:404/ the object is tooo big.");
  }*/
 /* else{Serial.print("\n error:404/no object detected ");}     //uncomment if you want to write it.*/
  }

Schematics

here is the circuit schematic
the wires are a bit jumbled. And use the IR sensors whose link is given in the components section and not the one in the CAD.
Capture mg2j9jrmm7
Test_Video
A Video showcasing a test run of the project. the speed gets printed in the serial monitor.
vid_20200428_213309_qzAgIOIIcL.mp4

Comments

Similar projects you might like

Ultrasonic Range Detector With Arduino

Project tutorial by Salman Faris

  • 30,757 views
  • 8 comments
  • 29 respects

Food Detector

Project tutorial by crispylel

  • 48,768 views
  • 11 comments
  • 106 respects

Motion Detector Clock

Project in progress by Frazer Reid

  • 3,116 views
  • 1 comment
  • 5 respects

Arduino EMF Detector A.K.A Ghost Detector

Project showcase by Patel Darshil

  • 14,248 views
  • 9 comments
  • 23 respects

A PM2.5 and PM 10 Detector design for Windows 10 UWP App

Project tutorial by Jiong Shi

  • 11,155 views
  • 6 comments
  • 24 respects

Healthcare Skin Pressure Detector

Project tutorial by David Escobar

  • 10,836 views
  • 3 comments
  • 21 respects
Add projectSign up / Login