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:
#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
}