So I was making an obstacle avoiding car and wrote this elaborate code which had a couple of errors but i removed them. However my car should turn when the ultrasonic sensors value for distance is equal to or lesser than zero but when i tested the code out, my car just went up and rammed in to the obstacle i.e door in this case. My ultrasonic also returns somwhat arbitrary values in between a set of normal values. Can someone kindly help me out? Feel free to go through the code again.
I have also attached a photo of serial monitor when the car is stationary.
Obstacle avoiding car.txt (4.34 KB)