กลับไปหน้ารวมไฟล์
is-the-overtaking-car-keeping-enough-side-distance-to-you-5c96ad-en.md

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.

Enhancing Cyclist Safety with Real-Time Proximity Monitoring

In many countries, traffic laws mandate a minimum side distance (often 1.5 meters) when a motorized vehicle overtakes a bicycle. This project reproduces a professional-grade monitoring tool using accessible Arduino components, allowing cyclists to objectively measure and record the proximity of overtaking vehicles.

Precision Ultrasonic Sensing in Traffic

The system relies on the HC-SR04 Ultrasonic Sensor, which operates by sending a 40kHz sonic burst and measuring the time it takes for the echo to return.

  • Distance Calculation: Using the formula Distance = (Time * Speed of Sound) / 2, the Arduino calculates the gap between the handlebar and the overtaking object.
  • Offset Calibration: A -20cm offset is included in the code to account for the sensor's mounting position relative to the edge of the bicycle.

Multi-Tiered Alert System

To provide immediate awareness to the cyclist without requiring them to look away from the road, the project uses a color-coded LED feedback system:

  • Green LED (150cm+): Safe overtaking distance maintained.
  • Yellow LED (100cm - 150cm): Warning - distance is below the recommended safety margin.
  • Red LED (30cm - 100cm): Danger - critical proximity violation that could lead to an accident.
  • Blue LED: System status or out-of-range indicator, ensuring the user knows the sensor is functioning even when no car is present.

User Interface and Data Readout

While the LEDs provide rapid feedback, a 16x2 LCD display shows the precise distance in centimeters. This is crucial for documentation or calibrating the device. The entire system is powered by a standard 9V battery and housed in a durable casing (in this case, a reinforced shoebox) mounted using standard GoPro-compatible hardware for maximum vibration resistance.

After The Idea

Due 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.

(on the left side is a wall aka car)

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.

ข้อมูล Frontmatter ดั้งเดิม

title: "Is The Overtaking Car Keeping Enough Side Distance To You?"
description: "Simple and effective method (some police is using too) how to measure the side distance to an overtaking car."
author: "theodorbenad"
category: "Sensors & Environment"
tags:
  - "traffic"
  - "driving"
  - "bicylce"
views: 5064
likes: 3
price: 1120
difficulty: "Easy"
components:
  - "1x Ultrasonic Sensor - HC-SR04 (Generic)"
  - "1x Rocker Switch, SPST"
  - "1x 9V battery (generic)"
  - "1x Cutter knife (generic)"
  - "1x 5 mm LED: Green"
  - "2x Resistor 100 ohm"
  - "1x Crimp Tool (generic)"
  - "1x 5 mm LED: Yellow"
  - "2x Through Hole Resistor, 150 ohm"
  - "1x Side cutter (generic)"
  - "1x Rotary potentiometer (generic)"
  - "1x Alphanumeric LCD, 16 x 2"
  - "1x Snap-on Connector, For 1 9-V Battery"
  - "1x 5 mm LED: Red"
  - "1x Soldering iron (generic)"
  - "1x 5 mm LED: Blue"
  - "2x Standard Terminal Block, Lever-Nuts"
  - "1x Jumper wires (generic)"
  - "1x Tape, Electrical"
  - "1x Arduino UNO"
  - "1x Breadboard (generic)"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles:
  - "https://projects.arduinocontent.cc/54c03059-17db-45b7-a1da-9b6c5b1a7693.ino"
  - "https://projects.arduinocontent.cc/54c03059-17db-45b7-a1da-9b6c5b1a7693.ino"
documentationLinks: []
passwordHash: "e9495704d1dbf73bf1a6ce0d51e975065d7260972a2528e41d3bd0f8c6e94094"
encryptedPayload: "U2FsdGVkX1+/25XERlv6DC3CLZdtxLv+DkjcN4ByMaiotEYAi1oIGvmuXX0TF8DpdawcMrQ8bhqxwfwop5wJoKF5kd0WxMSPcWzupYB1h7E="
seoDescription: "Measure side distance of overtaking cars with Arduino and Sensor. A simple, effective method used for road safety monitoring."
videoLinks:
  - "https://www.youtube.com/embed/NT-6R8LKlLI"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/is-the-overtaking-car-keeping-enough-side-distance-to-you-5c96ad_cover.jpg"
lang: "en"