Are you bored in traffic jams? Build your own traffic jam assistant for few dollars. TRAFFIGO (TRAFFIc GO) makes sound indication if you are approaching to a car in front of you (like parking sensor) and in additional makes different sound if the car in front of you is moving away.

With TRAFFIGO you will never miss time to go again and traffic will go more smoothly without unnecessary spaces and delays.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What Do You Need?

Step 2: How Does It Work?

Distance sensor is mounted in front bumper of your car and connected by wire to box with Arduino and buzzer in cabin. Arduino continuously measure distance, if distance is bellow limit (1m) sound indication is started with pause between beep corresponding to distance (higher distance = longer pause). As you are approaching car in front of you beeps are faster until you stop car.

If you’re your car and car in front of you are stopped and distance is not changing, TRAFFIGO stops indication and is quiet.

When car in front of starts moving away TRAFFIGO starts beeping again with different sound and you are announced to continue drive. When front car is away sounds stops again and nothing disturb you.

TRAFFIGO is powered from 12VDC car board voltage, e.g. from cigarette lighter socket.

Step 3: Connect Together

Step 4: Arduino Code


#include "Arduino.h"
int diffDistance = 1;

int diffDistanceTimeout = 500;
int toneDuration = 100;

int maxDistance = 100;

unsigned long lastDiffDistanceMillis;
unsigned long lastMillis;
const int buzzerPin = 8;
const int trigPin = 9;
const int echoPin = 10; int distance; int lastDistance; #include "filter.h"
ExponentialFilter distanceFiltered(16, 0);

const int c = 261; const int aH = 880;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

void loop() {
digitalWrite(trigPin, LOW);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); digitalWrite(trigPin, LOW);
long duration;
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
distance = distanceFiltered.Current();
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");

bool bBeep = true;
if(abs(lastDistance - distance) < diffDistance + (distance / 20)) {
if(millis() - lastDiffDistanceMillis > diffDistanceTimeout) {
bBeep = false;
else {
lastDiffDistanceMillis = millis();
if(distance > maxDistance) {
bBeep = false;
if(bBeep) {
if(millis() - lastMillis > distance * 4) {
lastMillis = millis();
if(distance > lastDistance)
tone(buzzerPin, c, toneDuration);
tone(buzzerPin, aH, toneDuration);
lastDistance = distance; } else { noTone(buzzerPin); } } else { noTone(buzzerPin); } }

#pragma once
/* Implements a simple linear recursive exponential filter. See: <a href="" rel="nofollow"> <a href=""> <a href=""> </a> </a> </a> */

template class ExponentialFilter {
// Weight for new values, as a percentage ([0..100])
T m_WeightNew;
// Current filtered value.
T m_Current;

ExponentialFilter(T WeightNew, T Initial): m_WeightNew(WeightNew), m_Current(Initial) {

void Filter(T New) {
m_Current = (m_WeightNew * New + (100 - m_WeightNew) * m_Current) / 100;

void SetWeight(T NewWeight) {
m_WeightNew = NewWeight;

T GetWeight() const {
return m_WeightNew;

T Current() const {
return m_Current;

void SetCurrent(T NewValue) {
m_Current = NewValue;

// Specialization for floating point math.
template<> class ExponentialFilter {
float m_fWeightNew;
float m_fCurrent;

ExponentialFilter(float fWeightNew, float fInitial) : m_fWeightNew(fWeightNew/100.0), m_fCurrent(fInitial) {

void Filter(float fNew) {
m_fCurrent = m_fWeightNew * fNew + (1.0 - m_fWeightNew) * m_fCurrent;

void SetWeight(float NewWeight) {
m_fWeightNew = NewWeight/100.0;

float GetWeight() const {
return m_fWeightNew*100.0;

float Current() const {
return m_fCurrent;

void SetCurrent(float fNewValue) {
m_fCurrent = fNewValue;
} };

Source code is available on Github

Step 5: Photos

Sensors Contest

Participated in the
Sensors Contest

Be the First to Share


    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest