title: Reading pic input on PIC12LF1552
body: <p>I'm working on a project and I need to use the PIC12LF1552. The code I'm trying to run is very simple, consists on reading the input on RA5 and then setting the output on RA2 to light an LED.<br>
  The problem is that it seems that the PIC is not reading the input on RA5. If I program the PIC to blink the LED without reading any input, it works correctly.<br>
  The program used to compile is MPLAB X 2.05, and the programmer being used is Pickit3.<br>
  The code that I'm using is this:</p>
  
  <pre><code>#include &lt;xc.h&gt;
  #include "pic12lf1552.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  // #pragma config statements should precede project file includes.
  // Use project enums instead of #define for ON and OFF.
  
  // CONFIG1
  #pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
  #pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
  #pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
  #pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
  #pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
  #pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
  #pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
  
  // CONFIG2
  #pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
  #pragma config STVREN = OFF     // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will not cause a Reset)
  #pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
  #pragma config LPBOR = OFF      // Low-Power Brown Out Reset (Low-Power BOR is disabled)
  #pragma config LVP = OFF        // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
  
  
  #define LED PORTAbits.RA2
  #define SWITCH PORTAbits.RA5
  
  void MSDelay (unsigned int);
  
  void main(void)
  {
      //Set up I/O pins
      TRISAbits.TRISA2 = 0; //RA2 = LED output
      TRISAbits.TRISA5 = 1; //RA5 = switch
      ADCON1=0b00100;
   //    ADCON1 = ;
      //int b;
     // int i;
  
  
  
      if(SWITCH == 0)
      {
          LED=1;
          MSDelay(2000);
          LED=0;
      }
      else
      {
          LED=0;
          MSDelay(2000);
      }
      }
  
  
  
  void MSDelay(unsigned int itime)
  {
      unsigned int i;
      unsigned char j;
      for(i=0; i&lt;itime;i++);
      for(j=0; j&lt;165;j++);
  }
  </code></pre>