|
Programming question
A couple of weeks ago, I wrote some code just to test out motor direction and then from there decided to write "real" code in the same file. Because easyC does not allow me to edit the text, I couldnt find a way to comment the test section of the code so I just made it an invalid while loop. (while(1==0)).
So when I ran the code, I noticed there was a rhythmic beep and silence pattern which corresponded to the same type of rhythmic motor control and lack of control. I figured out that it was the invalid while loop that was doing it.
Now I am experiencing a similar problem, but the rhythm of no control is much shorter. The only part of the code that would ever not be operation is a fairly large if statement. Is it possible for that if statement to cause a break in the code? Or could it have something to do with an undefinied variable?
#include "UserAPI.h"
int a = 0;
int b = 0;
int c = 0;
void main ( void )
{
while ( 1 )
{
MotorRcControl ( 0 , 2 , 3 , 0 ) ;
MotorRcControl ( 0 , 3 , 4 , 1 ) ;
MotorRcControl ( 0 , 6 , 1 , 1 ) ;
a = GetRxInput ( 1 , 5 ) ;
if ( a>127 )
{
SetPWM ( 2 , 160 ) ;
PrintToScreen ( "154\n" ) ;
}
else
{
if ( a<127 )
{
SetPWM ( 2 , 90 ) ;
PrintToScreen ( "100\n" ) ;
}
else
{
SetPWM ( 2 , 127 ) ;
PrintToScreen ( "127\n" ) ;
}
}
b = GetRxInput ( 1 , 6 ) ;
if ( b>127 )
{
SetPWM ( 1 , 144 ) ;
}
else
{
if ( b<127 )
{
SetPWM ( 1 , 110 ) ;
}
else
{
SetPWM ( 1 , 127 ) ;
}
}
}
}
__________________
Team 1546 Chaos Incorporated
2005- SBPLI Rookie All Stars
2006- SBPLI Sportsmanship award.
Gotta hand it to the straight line autonomous mode, the most effective defense out there.
Proud beyond belief of the accomplishments of the second year, 20th ranked, 6 wins and 6 losses Chaos Incorporated.
|