TheIdea
Until April 28, 2020 in Germany you have to keep at least 1.5 m (4.9 feet) side distance while overtaking a bicyle. If you violated the law you're going to receive a fine (30 EUR/34 USD).
But how does the police check the side distances between a car and a bicyle? During my research I found an article about the Salzburg's police department. I wondered how the device works so I tried to build one by myself.
After The IdeaDue to german/european law I would have to censor every license plate and every person. Because of that I couldn't record a video in action. But it's working well.
I would like to have a 3d printed case but I don't have a 3d printer so I took a stable shoe box. For mounting it to my handlebars I used some GoPro stuff.
In the code I'm operating only with centimeters.
#include <LiquidCrystal.h>
int trigger=7;
int echo=6;
int blue=8;
int green=9;
int yellow=10;
int red=13;
long distance,duration;
LiquidCrystal lcd(12,11,5,4,3,2);
void setup() {
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
lcd.begin(16,2);
pinMode(blue,OUTPUT);
pinMode(green,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(red,OUTPUT);
}
void loop() {
lcd.clear();
digitalWrite(trigger, LOW);
delay(5);
digitalWrite(trigger, HIGH);
delay(10);
digitalWrite(trigger, LOW);
duration = pulseIn(echo, HIGH);
distance = ((duration/2) * 0.03432) - 20;
lcd.print(distance);
if(distance>400 || distance<30){ //failure or not making sense to measure
digitalWrite(blue,HIGH);
digitalWrite(green,LOW);
digitalWrite(yellow,LOW);
digitalWrite(red,LOW);
}else if(distance<400 && distance>150){ //enough distance
digitalWrite(blue,LOW);
digitalWrite(green,HIGH);
digitalWrite(yellow,LOW);
digitalWrite(red,LOW);
}else if(distance<150 && distance>100){ //too little distance
digitalWrite(blue,LOW);
digitalWrite(green,LOW);
digitalWrite(yellow,HIGH);
digitalWrite(red,LOW);
}else if(distance<100 && distance>30){ //far too little distance
digitalWrite(blue,LOW);
digitalWrite(green,LOW);
digitalWrite(yellow,LOW);
digitalWrite(red,HIGH);
}
delay(100); //repeating fast enough to have a current value but slow enough having enough time to read the value
}
Here some pictures:
I was even able to drive normally without getting affected by the device.
I'm open to all (positive/negative...) feedback.
Comments