Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This scenario is regarding on how to measure the speed of a running car (or man)

ID: 2294051 • Letter: T

Question

This scenario is regarding on how to measure the speed of a running car (or man) from outside. The police department uses this type of system to prevent overspeeding of vehicles. This scenario is slightly different from the system used by the police, but the overall car speed detector concept is similar.

In this scenario, two IR sensors are placed apart on one side of the road. When any vehicle crosses the sensors, the internal timer Arduino counts the time between activation of the sensor. Now the speed is measured using simple distance-time relationship.

Both IR sensors are connected to the interrupt pins of the Arduino Uno, and they detect the falling wave. The purpose of using interrupts is that it improves the efficiency of the system. An LCD is connected to the Arduino and measured speed is shown on LCD.

When the car moves in front of the first sensor, it gives an output signal to Arduino, Arduino detects the falling wave, now internal timer of Arduino is started and when the car moves in front of the second sensor, the timer is stopped. Now, Arduino measures the speed of the car which is measured by distance-time relationship. Speed = distance/time.

When the speed detected is above 15 km/h, 2 LED will light up to warn the driver of over speeding.

The IR sensor includes an IR LED and a phototransistor. When an object passes between the sensors, light reflects from the object and falls on the phototransistor. An operational amplifier IC (LM358) is used and the phototransistor is connected to it. When an object comes in front of the sensor, it sends a logical HIGH signal to Arduino.

Component

Specification

Quantity

Arduino

Uno

1

IR Sensor

2

LED

Red

2

LCD Screen

16 x 2

1

Power Adapter

12 Volt

1

Switch

DPDT

1

Design a schematic diagram and come out with Arduino program codes to make this scenario work. A flow diagram would be useful. A diagram is shown below for illustration purposes.

Component

Specification

Quantity

Arduino

Uno

1

IR Sensor

2

LED

Red

2

LCD Screen

16 x 2

1

Power Adapter

12 Volt

1

Switch

DPDT

1

Proximity Sensors would be equipped on the first 2 lamppost to detect the speed of the oncoming PMD between this2 lamppost. LED would be placed at the subsequent 2 lamp post to warn the shared pedestrian user of the PMD approaching if the speed limit is above 15km/h on normal footpath and above 25km/h for shared pedestrian users.

Explanation / Answer

#include<LiquidCrystal.h>
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

int sensor1 = 2;
int sensor2 = 3;

int Time1;
int Time2;
int Time;
int flag = 0;

int distance = 27;

float Speed;

void setup() {
attachInterrupt(0,fun1,RISING);
attachInterrupt(1,fun2,FALLING);

lcd.begin(16,2);
lcd.clear();
lcd.print("SPEED MEASURMENT");
}

void fun1()
{
Time1 = millis();
if (flag == 0) {flag = 1;}
else {flag = 0;}
}

void fun2()
{
Time2 = millis();
if (flag == 0) {flag = 1;}
else {flag = 0;}
}


void loop() {
if (flag == 0){
if (Time1 > Time2) {Time = Time1 - Time2; Speed = (distance*1000)/Time;}
else if (Time2 > Time1) {Time = Time2 - Time1; Speed = (distance*1000)/Time;}
else {Speed = 0;}
}
  
if (Speed == 0) {
lcd.setCursor(0, 1);
lcd.print(".......OK.......");
}
else {
lcd.setCursor(2, 1);
lcd.print(Speed);
lcd.print(" cm/sec");
delay(10000);
Time1 = 0;
Time2 = 0;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote