QTR-8A not read correctly

The readLine() function returns a value between 0 and 1000 × N, where N is the number of sensors you are using minus 1. For example, if you are using 8 sensors, readLine() will return a number between 0 (when the line is under the first sensor) and 7000 (when the line is under the last sensor). Since you want the error to be 0 when the line is in the middle, you can set your error to readLine()-3500. This will result in an error value between -3500 and +3500, with 0 in the center.

It does not look like you have any calibration in the code you posted. As I mentioned before, unless you are just using the raw readings from the sensors, you should do a calibration. This calibration is required to scale the readings to better, more reliable values for your application. The readLine() function uses these calibrated readings and if you try to use it without calibrating the calibrated readings will just be 0 at all times. Also, please note that when you are calibrating, the sensors need to be exposed to the extremes you expect them to see during use, so you should make sure they all get passed over the black line and the white space on your course during calibration. In the examples I linked you to, the robot turns in place during calibration in order to move the sensors over the line so you do not need to manually move it.

Brandon