View Single Post
  #2   Spotlight this post!  
Unread 27-01-2015, 15:57
ForgotSemicolon's Avatar
ForgotSemicolon ForgotSemicolon is offline
I always forget those semicolons.
FTC #5998 (Ultraviolet)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Texas
Posts: 12
ForgotSemicolon is an unknown quantity at this point
Re: [FTC]: Programming a TETRIX Encoder - Wheel Problem

Hi Charging Champions!
I would recommend a function like the one below to use encoders.

void forward( int rotations, int power ){
motor[motor1] = 0;
motor[motor2] = 0;
//Resets the motor encoder readings.
while( nMotorEncoder[motor1] < rotations ){
motor[motor1] = power;
motor[motor2] = power;
}//goes forward until one of the two sides has rotated enough
}

Be sure to remember that it takes a lot of rotations to travel any distance at all!
Good Luck!
Reply With Quote