#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)
#pragma config(Motor, port2, rightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
wait1Msec(2000); //Robot waits for 2000 milliseconds before executing program
SensorValue[rightEncoder] = 0; //Set the encoder so that it starts counting at 0
while(SensorValue(rightEncoder) < 1800) //While rightEncoder has counted less than 1800 counts
{
//Turn Left
motor[rightMotor] = 127; //Motor on port2 is run at full (127) power forward
motor[leftMotor] = -127; //Motor on port3 is run at full (-127) power reverse
}
SensorValue[leftEncoder] = 0; //Set the encoder so that it starts counting at 0
while(SensorValue(leftEncoder) < 1800) //While leftEncoder has counted less than 1800 counts
{
//Turn Right
motor[rightMotor] = -127; //Motor on port2 is run at full (-127) power reverse
motor[leftMotor] = 127; //Motor on port3 is run at full (127) power forward
}
}
具体情况具体对待吧 其实ROBOTC软件里有编程范例