Rotating the Servo Using PID controller and SONAR

Thread Starter

nafis1401

Joined Sep 1, 2022
1
I have to make a bot which has front wheel steering by one servo motor like real cars..and one driving motor to run the robot..by rotating the servo the bot will turn right and left..there is Two SONAR on the left and right side to detect the distance from left and right wall. By taking the distance from both sides of the wall the robot has to be moved continuously forward at the middle position by steering the front wheel with help of the Servo.
How can I rotate the servo with PID for smooth turning? At 118degree the servo is straight and the robot is entirely forward. that means at 118degree of servo the robot will be completely straight.
How can I code the PID algorithm to rotate the servo by taking the distance from two sonar sensors?
1662016043661.png1662016062291.png
 
Top