Hey. I found out how to program the line tracking sensors. Now, what happens if the robot gets off the line? I am trying to figure out different ways for the robot to fix itself but I can’t seem to find the answer:confused:. Can someone please take a look at the code so far and add in whatever might work so I could get an idea of what to program? Thanks!!!
#pragma config(Sensor, in1, lineFollowerLEFT, sensorLineFollower)
#pragma config(Sensor, in2, lineFollowerCENTER, sensorLineFollower)
#pragma config(Sensor, in3, lineFollowerRIGHT, sensorLineFollower)
#pragma config(Motor, port2, leftMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port3, rightMotor, tmotorServoContinuousRotation, openLoop, reversed)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task main()
{
wait1Msec(2000);
int threshold = 1500;
while (1 == 1)
{
displayLCDCenteredString(0, “LEFT CNTR RGHT”);
displayLCDNumber(1, 0, SensorValue(lineFollowerLEFT), 4);
displayLCDNumber(1, 6, SensorValue(lineFollowerCENTER), 4);
displayLCDNumber(1, 12, SensorValue(lineFollowerRIGHT), 4);
if(SensorValue(lineFollowerLEFT) > threshold)
{
motor[leftMotor] = 63;
motor[rightMotor] = 0;
}
if(SensorValue(lineFollowerCENTER) > threshold)
{
motor[leftMotor] = 63;
motor[rightMotor] = 63;
}
if(SensorValue(lineFollowerRIGHT) > threshold)
{
motor[leftMotor] = 0;
motor[rightMotor] = 63;
}
}
}