esp8266 12E Car

I have made a wifi controlled car. The basic system is when I press a button on my phone, it sends data to the ip address of the esp8266 12e which is connected to my home network and then the data received by the wifi module performs it. For example, when I send 'right' to the esp8266 12e it turns the motor by using the l298n motor driver. Now I want to add the hcsr04 module to the car and when it detects a wall or something it should stop disregarding the data sent to the wifi module. But I went through weeks for searching how to do this and finally i found the code how to do this. I have pasted the code below which has been combined with the original sketch. But the car does not stop when it detects a wall. Please help me??

CAR.ino (5.76 KB)

First off, it is always a good idea to post any code using code tags so that people can read your code without having to download it. See post #7 of this thread for details.

WRT your distance sensor: assuming that the wiring is correct (it would be helpful to have a schematic) then the problem could either be with the arduino 'seeing' the wall, or with the arduino reacting to having seen the wall. If I were you I would add some simple way of seeing if the arduino have 'seen' an object in front of it- say turning on an LED. That will help you start to narrow down where the problem is.