In this post we are going to construct a circuit which can measure the speed of any vehicle on roads and highways. The proposed circuit is kept stationary at a place where the vehicles are suspected to over-speed. If any vehicle goes beyond the speed limit, the circuit alerts immediately. We will be looking the code, circuit diagram and logic how the speed of the vehicle is measured.
客观的
超速超速导致2015年意外死亡报告的道路事故发生了75%,这是一个巨大的数字。大多数交通警察试图拘留危险的驾驶者,他们危险地驱动他们的车辆超越城市限速。
不是每次交通警察都可以阻止超速车辆并充电。因此,安装了一个名为速度相机的设备,其中驾驶者被怀疑超过速度,例如频繁的事故易发的区域,交叉点等。
We are going to build something similar to speed camera, but in a much simplified way, which can be installed inside a campus such as school, college or IT parks or just as a fun project.
The proposed project consists of 16 x 2 LCD display to showcase the speed of each vehicle passing through; two laser beams which are placed apart exactly 10 meters to measure the speed of the vehicle while interrupting those laser beams.
当车辆通过时,蜂鸣器会发出蜂鸣声;指示检测到车辆并且将在LCD显示器上显示每个车辆的速度。当车辆超出速度限制时,蜂鸣器将连续发出蜂鸣声,并且将在显示屏上显示车辆的速度。
注意:无论车辆都超过速度或速度,液晶速度将显示在LCD上的速度。
现在让我们看看电路后面的逻辑以测量速度。
We all know a simple formula called speed – distance – time formula.
速度=距离/时间。
• Speed in meter per second,
• Distance in meter,
• Time in seconds.
要了解速度,我们必须知道距离说“X”由车辆和时间覆盖该距离“X”。
为此,我们正在建立两个激光束和两个LDR,以下列方式为10米的距离:
We know the distance is 10 meter which is fixed, now we have to know the time in the equation.
当车辆中断“启动激光器”时,将通过Arduino计算的时间,当车辆中断“结束激光器”时,计时器停止并将值施加到等式Arduino将找到车辆的速度。
请注意,仅在一个方向上检测车辆的速度即,启动激光器停止激光,以检测在另一个方向上的车辆另一个方向必须在相反方向上放置相同的设置。因此,这是学校,拼贴等的地方的理想选择。
现在让我们看看示意图:
Connection between Arduino and display:
上面的电路是自我解释的,只需根据电路连接接线。调整10K电位器以调节显示屏对比度。
额外的布线详情:
上述电路由Arduino,4个按钮组成,两个10k下拉电阻(不要改变电阻值),两个LDR和一个蜂鸣器。4个按钮的功能将很快解释。现在让我们看看如何正确装入LDR。
LDR必须正确地从阳光下覆盖,只有激光束应该打击LDR。确保您的激光模块足够强大,可以在明亮的阳光下工作。
您可以使用PVC管道以获得上述目的,并将其涂在管内;别忘了覆盖前部,用你的创造力来实现这一目标。
计划代码:
// ----------由r.girish开发--------- //
#include
#include
const int rs = 7;
const int en = 6;
const int d4 = 5;
const int d5 = 4;
const int d6 = 3;
const int d7 = 2;
液晶LCD(RS,EN,D4,D5,D6,D7);
const int = a0;
const int down = A1;
const int set = a2;
const int change = a3;
const int start = 8;
const int End = 9;
Const int蜂鸣器= 10;
const float km_h = 3.6;
int distance = 10; // In meters.
int variable = 0;
int数=0;
int address = 0;
int值= 100;
int speed_address = 1;
int speed_value = 0;
int i = 0;
float ms = 0;
浮动秒= 0;
浮动速度= 0;
boolean buzz = false;
boolean laser = false;
布尔x = false;
boolean y = false;
void setup()
{
pinMode(start, INPUT);
PinMode(结束,输入);
Pinmode(UP,输入);
PINMODE(向下,输入);
PinMode(设置,输入);
Pinmode(更改,输入);
Pinmode(蜂鸣器,输出);
DigitalWrite(改变,高);
digitalWrite(up, HIGH);
digitalWrite(down, HIGH);
digitalWrite(Set, HIGH);
digitalWrite(buzzer, LOW);
LCD.BEGIN(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(F(" Vehicle Speed"));
lcd.setCursor(0,1);
lcd.print(f(“探测器”));
delay(1500);
if (EEPROM.read(address) != value)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Set Speed Limit");
lcd.setCursor(0,1);
lcd.print("km/h:");
lcd.setCursor(6, 1);
lcd.print(计数);
而(x == false)
{
如果(DigitalRead(UP)==低)
{
lcd.setCursor(6, 1);
count = count + 1;
lcd.print(计数);
延迟(200);
}
if (digitalRead(down) == LOW)
{
lcd.setCursor(6, 1);
count = count - 1;
lcd.print(计数);
延迟(200);
}
if (digitalRead(Set) == LOW)
{
speed_value = count;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“速度限制为”);
lcd.setCursor(0,1);
lcd.print("set to ");
lcd.print(speed_value);
lcd.print(" km/h");
EEPROM.write(speed_address, speed_value);
delay(2000);
x =真;
}
}
EEPROM.write(address, value);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“测试激光”);
lcd.setCursor(0,1);
lcd.print(“对齐......”);
delay(1500);
而(激光== false)
{
if (digitalRead(start) == HIGH && digitalRead(End) == HIGH)
{
激光=真;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“激光对齐”);
lcd.setCursor(0,1);
lcd.print("Status: OK");
delay(1500);
}
while (digitalRead(start) == LOW && digitalRead(End) == LOW)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“两个激光器是”);
lcd.setCursor(0,1);
lcd.print(“未对齐”);
延迟(1000);
}
而(DigitalRead(START)==低)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Start Laser not");
lcd.setCursor(0,1);
lcd.print(“对齐”);
延迟(1000);
}
while (digitalRead(End) == LOW)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("End Laser not");
lcd.setCursor(0,1);
lcd.print(“对齐”);
延迟(1000);
}
}
lcd.clear();
}
void loop()
{
if(digitalread(更改)==低)
{
change_limit();
}
如果(digitalRead(开始)= =低)
{
variable = 1;
buzz = true;
while (variable == 1)
{
ms = ms + 1;
delay(1);
if (digitalRead(End) == LOW)
{
变量= 0;
}
}
秒= MS / 1000;
MS = 0;
}
if (Speed < EEPROM.read(speed_address))
{
y = true;
}
Speed = distance / Seconds;
速度=速度* KM_H;
if(Isinf(速度))
{
lcd.setCursor(0,0);
lcd.print(“速度:0.00”);
lcd.print(“km / h”);
}
别的
{
lcd.setCursor(0,0);
lcd.print(“速度:”);
lcd.print(速度);
lcd.print("km/h ");
lcd.setCursor(0,1);
lcd.print(" ");
如果(buzz == true)
{
buzz = false;
DigitalWrite(蜂鸣器,高);
延迟(100);
digitalWrite(buzzer, LOW);
}
if (Speed > EEPROM.read(speed_address))
{
lcd.setCursor(0,0);
lcd.print(“速度:”);
lcd.print(速度);
lcd.print("km/h ");
lcd.setCursor(0,1);
lcd.print(“超速警报!”);
如果(y == true)
{
y = false;
for (i = 0; i < 45; i++)
{
DigitalWrite(蜂鸣器,高);
延迟(50);
digitalWrite(buzzer, LOW);
延迟(50);
}
}
}
}
}
void change_limit()
{
x = false;
count = eeprom.read(speed_address);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Set Speed Limit");
lcd.setCursor(0,1);
lcd.print("km/h:");
lcd.setCursor(6, 1);
lcd.print(计数);
而(x == false)
{
如果(DigitalRead(UP)==低)
{
lcd.setCursor(6, 1);
count = count + 1;
lcd.print(计数);
延迟(200);
}
if (digitalRead(down) == LOW)
{
lcd.setCursor(6, 1);
count = count - 1;
lcd.print(计数);
延迟(200);
}
if (digitalRead(Set) == LOW)
{
speed_value = count;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“速度限制为”);
lcd.setCursor(0,1);
lcd.print("set to ");
lcd.print(speed_value);
lcd.print(" km/h");
EEPROM.write(speed_address, speed_value);
delay(2000);
x =真;
lcd.clear();
}
}
}
// ----------由r.girish开发--------- //
现在让我们看看如何操作此电路:
•完成您的电路并上传代码。
• The distance between two lasers / LDRs should be exactly 10 meter, no less or no more, Otherwise speed will be miscalculated (shown in the first diagram).
•激光和LDR之间的距离可以选择和情况。
•电路将使用LDR检查激光不对准,如果有任何请纠正LCD上显示的信息。
• Initially the circuit will ask you to enter a speed limit value in km/h beyond which the circuit alerts, by pressing up (S1) and down (S2) you can change the number on the display and press set (S3), this value will be saved.
•要更改此速度限制,请按按钮S4,您可以设置新的速度限制。
• Now take a motor bike drive at 30 km/h and interrupt the laser beams, the circuit should show you a number very close to 30 km/h.
•您已完成,您的电路已准备好为您的校园安全服务。
作者的原型:
如果对此交警速度探测器电路有任何疑问,请随时在评论部分询问,您可以快速回复。
可能在不遵循车道纪律的国家,如印度!