Distance measurement through back of car window

I'm contemplating whether its possible to measure the distance to the next car behind me in some easy way.

What I want to do is simple, if the car behind my car is closer than 10m, turn on a rather annoying (but not blinding) light pointing at them.

So, what is the best way to measure the distance to an object through a window. The accuracy needs to be in the region of ~10m +/- 1 meter.

migrated from arduino.stackexchange.comDec 29 '16 at 5:01

This question came from our site for developers of open-source hardware and software that is compatible with Arduino.

• I do it optically with a mechanical feedback actuator for the light. I.e., I look in my read view mirror and turn on my fog lights. 10m is a bit of a long distance for this kind of thing. 1m maybe it could be of some use, but 10m?! And what isn't blinding to you could be blinding to the old lady driving the 1975 maxi behind you... – Majenko Dec 28 '16 at 10:45
• Also, I don't know where you live, but in the UK there are strict laws governing what lights can be shown on a vehicle. – Majenko Dec 28 '16 at 11:21
• @Majenko Well it does not have to be lights, could be a LED sign with a well chosen word. – JensB Dec 28 '16 at 13:15
• Last time I checked LEDs were a form of light... sign shaped or not. – Majenko Dec 28 '16 at 13:18
• ... or offend the person behind you to such an extent that the ram you off the road. ;) – Majenko Dec 28 '16 at 13:31

The system should use the British "Only a fool breaks the 2-second rule" algorithm. That is, the safe distance between vehicles is 2 s. That means you need a velocity input into your system so that you can calculate the separation by $\Delta t = \frac {s}{v}$ where $\Delta t$ is the gap between the cars (s), $s$ is the distance (m) and $v$ is the velocity (m/s). The vehicle speed may be available from the CANBUS or from a GPS interface.