int CustomADC_Read (unsigned char k) // needs to be modified to get inut from user
{
int Adc_Result=0; // the variable that we will use to put the result of conversion in it
ADCON0=0b10000000;
ADCON0 = ADCON0|k<<3;
ADCON1=0b10000000;
ADCON0bits.ADON = 1; // start A/D converter module is powered up so this means
ADCON0bits.GO_DONE = 1; //that if A/D Conversion Status bit When ADON = 1 ,
// then A/D conversion in progress (setting this bit starts the
// A/D conversion which is automatically cleared by hardware when the A/D conversion is complete)
while(ADCON0bits.GO_DONE); //this will make it looping until conversion to finish
ADCON0bits.ADON = 0; //switch off adc so it consumes no power
Adc_Result = (ADRESH<<8)|ADRESL; // shifting ADRESH 8 times so we can add it to ADRESL , an so we can get the result correctly
return Adc_Result;
}