need some help with code

ok i tested the ping sensor by itself and it works the problem i m having is when everything is running my danger thresh hold does not appear to be doing what its supposed to (I.E. the robot is constantly moving forward and not stopping)