title: CCS conditional passing when it shouldn't
body: <p>Im working on a simple project making an elevator on proteus using CCS for the programming aspect, i have a display and a 4*3keypad and im using a pic16f877a, when going up there is message that says "subiendo..." (going up...), and when going down a message that says "bajando..." (going down...) and then show the floor you are currently on. The thing is that when i go down it shows the message of going up, but it does take me to the right floor, this is because it is somehow entering a if conditional when it shouldnt be entering it and i don't know why! please help.</p>
  
  <pre><code>#include &lt;16F877A.h&gt;
  #use delay(clock=8M)
  #fuses XT,HS,NOWDT,NOPUT,NOPROTECT,NOLVP
  
  #define LCD_ENABLE_PIN PIN_B0
  #define LCD_RS_PIN PIN_B1 
  #define LCD_RW_PIN PIN_B2
  #define LCD_DATA4 PIN_B4 
  #define LCD_DATA5 PIN_B5 
  #define LCD_DATA6 PIN_B6 
  #define LCD_DATA7 PIN_B7
  #define use_portb_kbd TRUE
  #include &lt;lcd.c&gt;
  #include &lt;kbd.c&gt;
  
  int piso;
  int x;
  
  
  /// main program
  void main()
  {       
  
  char destino;        
  
  
  lcd_init();
  
  kbd_init();
  port_b_pullups(TRUE);
  
  piso=1;  
  
  lcd_putc("\f Piso 1");
  while (true)            
  {               
    if(input(PIN_A5)==0)
    {
       destino=kbd_getc();
       x=destino-48;
  
       if(destino!=0)
       {
       if(x==piso)
       {
       }
       if((x&gt;piso)&amp;&amp;(x&lt;7))
       {
          piso=x;
          lcd_putc("\f Subiendo...");
          output_high(PIN_D6);        
          delay_ms(1000);
          output_low(PIN_D6);           
          printf(lcd_putc,"\f Piso %d", piso);
  
       }
  
       if((x&lt;piso)&amp;&amp;(x&gt;0))
       {
          piso=x;
          lcd_putc("\f Subiendo...");
          output_high(PIN_D6);        
          delay_ms(1000);
          output_low(PIN_D6);           
          printf(lcd_putc,"\f Piso %d", piso);
  
       }
    }
    }
    else
    {
       lcd_putc("\f Limite de peso \n excedido");
       delay_ms(500);
       printf(lcd_putc,"\f Piso %d", piso);
       delay_ms(500);
  
    }
  
   }                    /// fin de bucle while
  } 
  </code></pre>