[FTC]: Light Senser

My code is trying to use the light senser to follow the white lines during autonomous. I have seen other teams do this and i was wondering if someone could post some code for it.
Thanks:D

here is some basic code that will drive until your sensor hits the line:


motor[drive_right] = 100;       //start driving the motors
motor[drive_left] = 100;
while (SensorRaw[lightSensor] < tapeColor);      //keep driving until you run over the tape, tapeColor is a variable determined by the lighting and color of the tape, we used 340.
motor[drive_right] = 0;       //stop
motor[drive_left] = 0;

following the line is a bit tougher, the general idea is to go straight unless the light sensor goes off the line, if it does, turn until it is on the line again. Good luck getting it working, and if you need another hint, just ask!

On important thing is make sure you declare tapecolor with

int tapecolor = ____;

As for following the line, i would highly recommend two sensors for line following, just so you get a good tracking.