I have Been troubleshooting this code for about a week now and I still can not get it to count in the if loops, all of the variables are correct, but it will not count in the loops. help?
#include "Main.h"
void Autonomous ( unsigned long ulTime )
{
StartQuadEncoder ( 4 , 5 , 0 ) ; // Left Drive
StartQuadEncoder ( 6 , 7 , 1 ) ; // Right Drive
StartGyro ( 3 ) ;
Potentiometer = GetAnalogInput ( 1 ) ; // Autonomous Select
Auto_Jumper = GetDigitalInput ( 10 ) ;
Left_Drive_Encoder = GetQuadEncoder ( 1 , 2 ) ; // Left Drive Encoder
Right_Drive_Encoder = GetQuadEncoder ( 3 , 4 ) ; // Right Drive Encoder
Gyro = GetGyroAngle ( 3 ) ; // Gyro
InitLCD ( 1 ) ;
SetLCDLight ( 1 , 1 ) ;
while ( 1 )
{ if ( Auto_Jumper == 0 ) // Jumper In = Auto Enable
{ if ( Potentiometer >= 0 && Potentiometer <= 256 )
{ Wait ( 250 ) ;
Reset_Encoders ( ) ;
while ( Left_Drive_Encoder <= 1000 )
{
if ( Left_Drive_Encoder > Right_Drive_Encoder )
{
Drive_Forward_Slow_Left ( ) ;
}
else if ( Right_Drive_Encoder > Left_Drive_Encoder )
{
Drive_Forward_Slow_Right ( ) ;
}
else if ( Left_Drive_Encoder == Right_Drive_Encoder )
{
Drive_Forward ( ) ;
}
}
while ( Gyro < -900 )
{
Turn_Left ( ) ;
}
Reset_Encoders ( ) ;
while ( Left_Drive_Encoder <= 1000 )
{
if ( Left_Drive_Encoder > Right_Drive_Encoder )
{
Drive_Forward_Slow_Left ( ) ;
}
else if ( Right_Drive_Encoder > Left_Drive_Encoder )
{
Drive_Forward_Slow_Right ( ) ;
}
else if ( Left_Drive_Encoder == Right_Drive_Encoder )
{
Drive_Forward ( ) ;
}
}
Drive_Stop ( ) ;
}
else if ( Potentiometer >= 257 && Potentiometer <= 512 )
{
Wait ( 250 ) ;
Reset_Encoders ( ) ;
while ( Left_Drive_Encoder <= 1000 )
{
if ( Left_Drive_Encoder > Right_Drive_Encoder )
{
Drive_Forward_Slow_Left ( ) ;
}
else if ( Right_Drive_Encoder > Left_Drive_Encoder )
{
Drive_Forward_Slow_Right ( ) ;
}
else if ( Left_Drive_Encoder == Right_Drive_Encoder )
{
Drive_Forward ( ) ;
}
}
while ( Gyro < 900 )
{
Turn_Right ( ) ;
}
Reset_Encoders ( ) ;
while ( Left_Drive_Encoder <= 1000 )
{
if ( Left_Drive_Encoder > Right_Drive_Encoder )
{
Drive_Forward_Slow_Left ( ) ;
}
else if ( Right_Drive_Encoder > Left_Drive_Encoder )
{
Drive_Forward_Slow_Right ( ) ;
}
else if ( Left_Drive_Encoder == Right_Drive_Encoder )
{
Drive_Forward ( ) ;
}
}
Drive_Stop ( ) ;
}
else if ( Potentiometer >= 513 && Potentiometer <= 768 )
{
}
else if ( Potentiometer >= 767 && Potentiometer <= 1024 )
{
}
}
if ( Auto_Jumper == 1 ) // Jumper Out = Auto Disabled
{
}
}
}