Ultrasonic Sensor for smart traffic light detection

Customer:

I’m working on a final project for a smart traffic light. I need help with an ultrasonic sensor. I need to create an interrupt using it so that the red light only breaks when a car is in front, but not every time a car arrives. I understand how the sensor works but I don’t know how to implement the interrupt with it.

Original message (Croatian)

Dobar dan.Imam završni rad na temu pametnog semafora.Da li mi možete pomoći oko ultrazvučnog senzora.Trebam napraviti prekid pomoću njega tako da mi samo ako je auto ispred prekine samo crveno svijetlo ali samo mora prekidati crveno svijetlo.Znaci ne svaki put prekidati ako naiđe auto.Razumijem kako radi senzor ali neznam izvesti prekid s njim.Hvala

Originally submitted via email support on 22 April 2018. Migrated to the forum for community visibility.

Soldered Support:

You can measure the time when a car is in front of the sensor and control the traffic light accordingly. Your code should look like this:
Step 1: detect if a car is in front of the sensor
Step 2: create a pause of x seconds (calibrate the x time)
Step 3: detect again if a car is in front of the sensor - if it is, the car was stationary

More advanced code would be to constantly check if a car is in front and simultaneously count the time.

We cannot write the code for you as that falls outside the scope of our technical support.

Original message (Croatian)

hvala Vam na upitu.

Možete mjeriti vrijeme kada je auto ispred senzora i prema tome kontrolirati semafor. Dakle, kod Vam treba izgledati:
korak 1. detektiraj jel auto ispred senzora
korak 2. napravi pauzu od x sekundi (kalibrirati x vrijeme)
korak 3. detektiraj opet jel auto ispred senzora - ako je, auto je stojao

napredniji kod bi bio konstantno provjeravati jel auto ispred i istovremeno brojati vrijeme.

Nažalost, mi Vam ne možemo napisati kod jer to ne pripada u opseg naše tehničke podrške.