Help Please: Use PID to control servo motor (pixy CMUcam 5 with arduino and 1 servo motor)

Hi, I am working on a fusion of image and sonar based robotic fish. I use pixy CMUcam 5 with arduino and 1 servo motor to move(Right,left and forward) direction. I want to use PID to control servo motor. Tell me how to do this. I give different values of x to detect the object in three direction( right, left and forward) then tell servo if this angle move in ( right, left and forward) direction.

Hey,

If this is your first time doing a PID, some reading will be required first. You may want to start with something more general, such as this Wikipedia page.

A quick online search for “Arduino PID” finds many useful results, such as:
Arduino Playground’s PID example (Brett’s), with details from Brett here and the GitHub here.
There’s also this nice write-up here on HaD.

Sincerely,