No matter what speed or distance I put this at, when I try to turn it goes 180 degrees. Thank you if you can help.
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1, rightSide, sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_2, leftSide, sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, LiftLeft2, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, frontLeft, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port3, frontRight, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port4, rearRight, tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, I2C_1)
#pragma config(Motor, port5, rearLeft, tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_2)
#pragma config(Motor, port6, LiftLeft1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, LiftRight1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, DumpsterLeft, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, DumpsterRight, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port10, LiftRight2, tmotorVex393_HBridge, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "Voids.c"
task main()
{
turn(20, 1);
}
Voids.c
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1, rightSide, sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_2, leftSide, sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, LiftLeft2, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, frontLeft, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port3, frontRight, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, rearRight, tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor, port5, rearLeft, tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_2)
#pragma config(Motor, port6, LiftLeft1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, LiftRight1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port8, DumpsterLeft, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, DumpsterRight, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port10, LiftRight2, tmotorVex393_HBridge, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void turn(int speed, int distance)
{
nMotorEncoder[rearRight] = 0;
nMotorEncoder[rearLeft] = 0;
while(abs(nMotorEncoder[rearRight]) < distance*22.5 || abs(nMotorEncoder[rearLeft]) < distance*22.5){
motor[frontLeft] = speed;
motor[frontRight] = speed;
motor[rearLeft] = speed;
motor[rearRight] = speed;
}
motor[frontLeft] = 0;
motor[frontRight] = 0;
motor[rearLeft] = 0;
motor[rearRight] = 0;
}