Help me to add sensor distance on my app

I want an app to show obstacle and position and as soon as the position is activated it changes the color of the chosen side