Daniel Morley

adding variables

Discussion created by Daniel Morley on Dec 29, 2006
Latest reply on Dec 29, 2006 by Daniel Morley
Before any one jumps on my case I have read most of ansi C programming guide.  In the guide I did notice that to add one to an integer one simply  integer= integer + 1 or ++integer.  I have tried this and it does not seem to work. In the following code
 
 void ManualControl(){
   int position;
   int stop;
 
   stop=0;
   position=0;
  if(Button1 == UP||Button2 == UP ) {
    
  while (Button1 == UP){
  Reverse();   
  position=ReadPosition(position);
           stop=position;
             stop=position-1;
     //  if (stop==-1)
     // stop=15;
  
  
  } 
  
  
  while (Button2 == UP){
   Forward();
   position=ReadPosition(position);
         stop=position;
         stop=position+1;  
    //   if (stop==16)
  //    stop=0;
           
     
    
  }        
   
  
 
       while (position != stop) {
   
   position=ReadPosition(position);
  }
 
 Brake();
 
  }
  }
   
 
This code works fine till I add a 1 to stop and then it stays in the last while statement indefinitely. 

Outcomes