title: Can only read once from PIC16's RCO port
body: <p>Been searching for an answer for this for a few days now.  I'm trying to create this simple verification program where if I push a button it drives the voltage on <code>RC0</code> to 5 volts, and when the button is unpushed, a pulldown resistor pulls the pin down to 0.  The problem is, the code will only work the first time I push the button.  After that it will not enter the <code>if (RC0 == 1)</code> loop.   Here is my code snippet.  What am I missing here?</p>
  
  <pre><code>void main(void){
      /* Configure the oscillator for the device */
      ConfigureOscillator();
  
      /* Initialize I/O and Peripherals for application */
      InitApp();
  
      TRISB = 0x0F;         // turn on RB7 for use as output
      TRISC = 0xFF;         //  turn on RC0 for use as input
      ANSEL = 0b11101111;   //  use RC0 as digital input
      unsigned char time = 0;
  
      while (1) {
          //delay for 10 seconds
          if (PORTCbits.RC0 == 1) {
              while (time &lt; 10) {
                  /* TODO */
                  RB7 = 1;
                  __delay_ms(100);
  
                  RB7 = 0;
                  __delay_ms(100);
                  time++;
              }
          }
  
          if (PORTCbits.RC0 == 0){ //This if statement will always execute when 
                                   //RC0 == 0, but will not execute when I push 
                                   //the button.  This really confuses me.  
                                   //Can RCO be given a value different than 1?
              __delay_ms(2000);
          }
  
          RB7 = 0;
          __delay_ms(500);
          RB7 = 1;
          __delay_ms(500);
  
      }
  
  }
  </code></pre>