I have students who are using a 3 line tracker. The code they have written works for the right and left side, but the middle line sensor won’t work. I have double checked the ports and motor set-up. They are set up for line sensors. Here is the code that we have been using.
#pragma config(Sensor, in1, leftlinesensor, sensorLineFollower)
#pragma config(Sensor, in3, rightlinesensor, sensorLineFollower)
#pragma config(Sensor, in4, middlelinesensor, sensorLineFollower)
#pragma config(Sensor, dgtl6, button, sensorDigitalIn)
#pragma config(Motor, port1, leftmotor, tmotorVex393_HBridge, openLoop, driveLeft)
#pragma config(Motor, port10, rightmotor, tmotorVex393_HBridge, openLoop, reversed, driveRight)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
task main()
{
while(1==1){
if(SensorValue(button) == 0)
{
motor[leftmotor] = -127;
motor[rightmotor] = -127;
}
if(SensorValue(middlelinesensor) > 505){
motor[leftmotor] = 100;
motor[rightmotor] = 100;
}
if(SensorValue(leftlinesensor) > 505){
motor[leftmotor] = 127;
motor[rightmotor] = 0;
}
if(SensorValue(rightlinesensor) > 505){
motor[leftmotor] = 0;
motor[rightmotor] = 127;
}
}
}