int power_difference = proportional/20 + integral/10000 + derivative*3/
I am making a robot using pololu QTR8C sensor. Please advice what is the part i should change from the above PID code when the distance between motor and sensor increased
The coefficients used in that PID control equation were specifically set to be a good starting point in an example line following script for our 3pi robot. Since you are making your own robot, which could have very different characteristics (i.e. different motor power, wheel diameter, distance between sensors and motors, etc.) those coefficients are likely not very appropriate for your system. It would be more straightforward and reasonable to start with your own custom control input values. In general, a good way to start figuring this out is by focusing on just the proportional term (i.e. test your line following code with derivative and integral coefficients set to 0). You can get a better sense for how to get started doing that in this post by Ben.