View Single Post
  #1   Spotlight this post!  
Unread 08-03-2008, 11:02
Lakeeffect1674 Lakeeffect1674 is offline
Registered User
FRC #1674
 
Join Date: Jan 2007
Location: Onekama, Michigan
Posts: 18
Lakeeffect1674 is an unknown quantity at this point
Code error with while loops??

-History-
I am a student who is currently learning C++, so I know simple commands like a while statement.
I was able to get this code working when I program a PC.
I searched the web for help but found nothing
----==================
Now when I program the Robot using C I get it to do a loop but after a few times the bot will say code error.
I just want the robot to travel for a certain number of seconds.
here is my code what is wrong? or is there a better way to have a robot on a timer?
(this code is under the void Autonomous(void) function)


if(stop == 0)
{
timer = 900;
while(timer > 0)
{
timer = timer - 1;
printf( "timer is %d\n", timer );
pwm13 = pwm14 = pwm15 = pwm16 = 255;
}

stop = 1; // this should make sure the code wont run again
}
printf( "stop is %d\n", stop );
pwm13 = pwm14 = pwm15 = pwm16 = 127;
printf( "pwm13 is %d\n", pwm13 );

Last edited by Lakeeffect1674 : 08-03-2008 at 11:04.