8051 help ..#2

Ian Rogers

Joined Dec 12, 2012
1,136
If... else if... else if... Ergo if condition 1 is true nothing else gets done..

Change the last two to a seperate conditional if statement.
C:
while(1)
   {
   if(s1==1)
      {
      while(s2==0);
      if(count!=99)
      count=count+1;
      while(s2==1);
      view(count);
      }
   else if(s2==1)
      {
      while(s1==0);
      if(count!=0)
      count=count-1;
      while(s1==1);
      view(count);
   }
if(count==0)
   relay=1;
else 
   relay=0;
}
Other wise it won't do what you thinhk
 
Top