Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/09/03 21:17
Read: times


 
#56443 - RE: break sequence
Responding to: ???'s previous message
Oleg is right.With your code as written you will always be stuck in one of the two while loops if P3.2 and P3.3 are high (==1) at the same time.
You must either switch your inputs at the same time, such that only one input is high at any time or allow for this condition in your software.There are probably better ways but you could use logical operator && for example:

while(1)
{
while(P3_2==1 && P3_3==0);
delay(50); //delay to debounce
for(i=0;i<12;i++)
{
P1=~tled1[i];
delay(75); //flashing sequence
if(P3_3==1) //exit to other sequence
break;
}

while(P3_3==1 && P3_2==0);
for(i=0;i<12;i++)
{
P1=~tled2[i];
delay(75); //flashing sequence
if(P3_2==1) //exit to other sequence
break;
}
while(P3_3==1 && P3_2==1);
for(i=0;i<12;i++)
{
P1=~tledX[i]; //where x is some other sequence
delay(75); //flashing sequence
if(P3_2==1) //exit to other sequence
break;
}

}


Since you are using four inputs I think this method would be a little cumbersome though and I would be tempted to rethink the flow of this program .

Hope that is a little helpful.
Phil.


List of 9 messages in thread
TopicAuthorDate
break sequence            01/01/70 00:00      
   RE: break sequence            01/01/70 00:00      
   RE: break sequence            01/01/70 00:00      
   RE: break sequence            01/01/70 00:00      
   RE: break sequence            01/01/70 00:00      
   RE: break sequence            01/01/70 00:00      
   RE: Better Approach            01/01/70 00:00      
      RE: Better Approach            01/01/70 00:00      
         RE: Better Approach            01/01/70 00:00      

Back to Subject List