Need help with light sensor when running into black line

Hello. I am in the process of making my 3pi able to be controlled by an android phone. I have all the controls working, and it is driving fine. Now all i need to do is make it so that when the 3pi runs into a black line it will not be able to drive forward any more, and it will then only be able to drive backwards. I have the code for the motor control, but i am having a hard time with the light sensor code. can anyone help me?
Here is what I have so far:

[code]#include <OrangutanMotors.h>.
#include <Pololu3pi.h>
#include <PololuQTRSensors.h>
#include <avr/pgmspace.h>
#include <OrangutanBuzzer.h>
OrangutanMotors::setSpeeds(0, 0);
void setup()
{

}
motors.setSpeeds(motorspeed, motorspeed2);
int motorVariable //the motorVariable is the motor speed that is being given from previous code
int motorspeed = motorVariable
int motorspeed2 = motorVariable
int bool = 0
unsigned int sensor_values[5];
read_line_sensors(sensor_values);
void emitters_on()
void calibrate_line_sensors(unsigned char readMode)

void loop()
// i want the light sensor to read the ground during this loop. I want it to change the Bool value to 0 if there is a black line in the way, and for all other cases have the bool value be 1

void loop ()
{
if (bool = 0)
if motorspeed > 1 && motorspeed2 > 1
mototrspeed2 = motorspeed2*(-1)
motorspeed = motorspeed*(-1)

if (bool = 1)
motorspeed = motorVariable
motorspeed2 = motorVariable
}[/code]

Hello.

I am not entirely sure I know what it is you want to do; it sounds like you might want your 3pi to go only in reverse after encountering a black line, or maybe just stay within the confines of a black line. Can you please elaborate? (Without knowing what you are specifically trying to achieve, it is difficult for me to recommend anything.)

In either case, you might be able to get a better idea of how to write your code by reading about how the 3pi’s sensors work inside the “QTR Sensor Functions” section of our AVR C/C++ Library User’s Guide.

-Jon