Re: Infrared sensor how to program?
Kp is the Proportional Constant in PID control. If you are not familiar with PID control, you can read the following article.http://en.wikipedia.org/wiki/PID_control
Basically, it said the output power of the motor should be proportional to how far you are from your target. If you are very far from your target, PID control will try to drive with maximum power. If your are very close to your target, PID control will slow down so you don't overshoot. Kp is a constant you must tune so that it's value is big enough to get the robot to target as fast as possible and yet not overshooting. To tune this value, you can try something big first. If it overshoots and oscillates when reaching target, tune this value smaller until it no longer oscillates. PID control involves other constants too, but if you are not familiar with it, you can just use Kp and ignore the other constants.
In the IRDrive function, Kp is to control how quickly the robot turns towards the IR. The bigger Kp the faster it will turn towards the IR but risking overshooting (turn too much). The smaller Kp the slower it will turn to the IR but more accurate. You can try an initial value of 20 to 25 and see how it goes and tune it from there.