Labs/Lab6/Watkins_William_Lab6_Part2.c
// <editor-fold defaultstate="collapsed" desc="readADC()">
/******************************************************************************
 * readADC function
 *
 * Reads temp or pot values from ADC and stores them in global variable
 ******************************************************************************/

readADC function

Reads temp or pot values from ADC and stores them in global variable
readADC function Reads temp or pot values from ADC and stores them in global variable
void readADC() {
    __delay_us(4);
    ADCON0bits.GO = 1;
    while(ADCON0bits.GO) {} 
    trash = ADRES; 
    ADCON0bits.GO = 1;
    while(ADCON0bits.GO) {}
    if (sensor != 1) {
        temperature = ADRES;
    }
    else if(sensor == 1) {
        potentiometer = ADRES;
    }
}
void readADC ( ) { __delay_us ( 4 ) ; ADCON0bits . GO = 1 ; while ( ADCON0bits . GO ) { } trash = ADRES ; ADCON0bits . GO = 1 ; while ( ADCON0bits . GO ) { } if ( sensor != 1 ) { temperature = ADRES ; } else if ( sensor == 1 ) { potentiometer = ADRES ; } }
<editor-fold defaultstate="collapsed" desc="readADC()">
 readADC function
<editor - fold defaultstate = " collapsed " desc = " readADC () " > readADC function
// Wait after starting the ADC conversion // trash the first variable