CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

restarting loop
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 01, 2009 6:23 pm     Reply with quote

Another method is, if you want to jump back to the top of a loop,
you can use the 'continue' statement. Then exit the loop with
the 'break' statement. See this thread for an example:
http://www.ccsinfo.com/forum/viewtopic.php?t=19704&highlight=continue
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Dec 02, 2009 3:30 am     Reply with quote

This is my recomendation:-

Change obsticle to
Code:

         if(act_dist <= 15)
           return;


or

Code:

         if(act_dist > 15)
        {
           steer = STOP;
           LFR_STEER();
           delay_ms(500);
         
           steer = MOVE_FORWARD;
           LFR_STEER();
           delay_ms(1000);
           steer = STOP;
           LFR_STEER();
           delay_ms(500);
           steer = ROTATE_LEFT;
           LFR_STEER();
           delay_ms(1000);
         
         //  ultrasonic();
                 
           steer = MOVE_FORWARD;
           LFR_STEER();
         
           if (input(PIN_A0) == 1)
           {
               steer = ROTATE_RIGHT;
               LFR_STEER();
               i=0;
            }
         }
}   


and make this change in main

Code:

     i=1;
     while (act_dist <= 15)
      {
       obstacle( );
      }

 
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group