Use this video to learn about the difficulties of having a robot stop when it sees an obstacle:
http://curriculum.cs2n.org/ev3/lesson/media_videos/9_3_switchloops.mp4 [1]
NOTE: the programming screen shots are from the full PC version of the LEGO programming software, not the App versions (Chromebook, iPad or Win10) so you will need to follow along with the interface you are using.