Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 4930

how to compare values using if statement

$
0
0
I have the following code(shorted) and want to compare values from timer register after converting to decimal in the if statement, how to do this? its for PIC16F877A using XC8 compiler...

Code (Text):
  1. time_taken = (TMR1L | (TMR1H<<8));
  2. distance= (0.0272*time_taken)/2;
  3.  
  4. d1 = (distance/100)%10;
  5.         d2 = (distance/10)%10;
  6.         d3 = (distance/1)%10;
  7.  
  8. //then want to compare and take action using if statement
  9.  
  10. if( ){
  11.         RB4 = 1;
  12.         }
  13.      else{  
  14.         RB4 = 0;
  15.         }

Viewing all articles
Browse latest Browse all 4930