I tried using the line follower sensor and ultrasonic sensor to create a line follower car which will display the red LED light, and stop (see the code in pic1) or run backward (see the code in pic2) when there is an obstacle in front of the car within 3 cm. I found that the car sometimes (or even often) displayed the red LED light, and stop or run backward while there is no obstacle in front of the car within 3 cm, and sometimes I have to put my hand in front the car and move my hand more than 3 cm in front of it to make it move forward again, but then it will display do such action again though there is no obstacle in front of the card. Is the ultrasonic sensor out of order? Or any coding skills/technique about the ultrasonic sensor thatt could help to resolve such problem?
pic1.
Uploading…
pic2
Uploading…