Please or Register to create posts and topics.

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.

Project description

  1. IR sensor based speed detection project.
  2. 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.

the full setup !!!!

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_detection101

arduino

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("
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("
Error:404/ the object is tooo big.");
}*/
/* else{Serial.print("
error:404/no object detected ");} //uncomment if you want to write it.*/
}

Downloadable files

Test_Video

A Video showcasing a test run of the project. the speed gets printed in the serial monitor.

[video src="https://projects.arduinocontent.cc/a9ee288f-c1fa-4442-aec8-78c94ebecacd.mp4" /]

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.

https://projects.arduinocontent.cc/088ddb00-14d0-4ac7-8b8b-c786e35baf13.PNG