Help - Collision Avoidance System

I am a spanish student with no idea
I wanted to introduce a collision system with ultra sounds in this software.
The main question is how to link my code to it so that it runs in a single flight mode.
Someone could guide me a bit with information or topics to invest thanks.