Coding & Debugging Parts – Ultrasonic Sensor

After the Bluetooth solution failed, we enabled an alternative – ultrasonic sensors. With previous experience, the testing process went smoothly this time, and we initially completed the wiring and coding. Initially we tested its two basic elements, distance and accuracy. After several rounds of testing, the distance of the ultrasonic sensor has met our requirements, but the accuracy barely meets the requirements under flat testing, but the accuracy will drop a lot when facing irregular objects. Based on this feature, we finally placed it on both sides of the robot for obstacle avoidance sensors, where it can play a role.

             

In the coding test part, we divide it into two parts. One is distance measurement. Its principle is to use an ultrasonic sensor to emit ultrasonic waves and recycle them, and measure the distance based on the propagation delay between them. The other part is to tell the robot which direction it should turn by collecting and comparing the difference in distance detected by the two ultrasonic waves. The instructions processed by Arduino will be conveyed to the servo motor to control the front wheel steering.