Labs/Lab6/Watkins_William_Lab6_Part2.c
// <editor-fold defaultstate="collapsed" desc="handleADC()">
/******************************************************************************
 * handleADC function
 *
 * Calls readADC() to read both temperature and potentiometer values.  After
 * reading the temperature data, the channel is changed, the first read flag is set,
 * and the sensor flag is changed.  After the potentiometer value is read, both 
 * values are converted to doubles, and then stored in the appropriate strings
 * for output via EUSART or to LCD.
 ******************************************************************************/

handleADC function

Calls readADC() to read both temperature and potentiometer values.  After
reading the temperature data, the channel is changed, the first read flag is set,
and the sensor flag is changed.  After the potentiometer value is read, both
values are converted to doubles, and then stored in the appropriate strings
for output via EUSART or to LCD.
handleADC function Calls readADC () to read both temperature and potentiometer values . After reading the temperature data the channel is changed the first read flag is set and the sensor flag is changed . After the potentiometer value is read both values are converted to doubles and then stored in the appropriate strings for output via EUSART or to LCD .
void handleADC() {
    readADC();
    ADCON0bits.CHS = 0b00000;   
    firstread = 1;  
    sensor = 1;     
    readADC();
    ADCON0bits.CHS = 0b00011;   
    firstread = 1;
    sensor = 0;
    temp = temperature * 0.0806;
    pot = potentiometer * 0.000806;
    sprintf(potLCD, "%1.2f", pot);
    row2LCD[4] = potLCD[0];
    row2LCD[6] = potLCD[2];
    row2LCD[7] = potLCD[3];
    potSend[0] = potLCD[0];
    potSend[2] = potLCD[2];
    potSend[3] = potLCD[3];
    contSend[12] = potLCD[0];
    contSend[14] = potLCD[2];
    contSend[15] = potLCD[3];
    sprintf(tempLCD, "%2.1f", temp);
    if (temp<10.0) {
        row1LCD[3] = '0';
        row1LCD[4] = tempLCD[0];
        row1LCD[6] = tempLCD[2];
        tempSend[0] = '0';
        tempSend[1] = tempLCD[0];
        tempSend[3] = tempLCD[2];
        contSend[2] = '0';
        contSend[3] = tempLCD[0];
        contSend[5] = tempLCD[2];
    }
    else {
        row1LCD[3] = tempLCD[0];
        row1LCD[4] = tempLCD[1];
        row1LCD[6] = tempLCD[3];
        tempSend[0] = tempLCD[0];
        tempSend[1] = tempLCD[1];
        tempSend[3] = tempLCD[3];
        contSend[2] = tempLCD[0];
        contSend[3] = tempLCD[1];
        contSend[5] = tempLCD[3];
    }
}
void handleADC ( ) { readADC ( ) ; ADCON0bits . CHS = 0b00000 ; firstread = 1 ; sensor = 1 ; readADC ( ) ; ADCON0bits . CHS = 0b00011 ; firstread = 1 ; sensor = 0 ; temp = temperature * 0.0806 ; pot = potentiometer * 0.000806 ; sprintf ( potLCD , " " , pot ) ; row2LCD [ 4 ] = potLCD [ 0 ] ; row2LCD [ 6 ] = potLCD [ 2 ] ; row2LCD [ 7 ] = potLCD [ 3 ] ; potSend [ 0 ] = potLCD [ 0 ] ; potSend [ 2 ] = potLCD [ 2 ] ; potSend [ 3 ] = potLCD [ 3 ] ; contSend [ 12 ] = potLCD [ 0 ] ; contSend [ 14 ] = potLCD [ 2 ] ; contSend [ 15 ] = potLCD [ 3 ] ; sprintf ( tempLCD , " " , temp ) ; if ( temp < 10.0 ) { row1LCD [ 3 ] = ' ' ; row1LCD [ 4 ] = tempLCD [ 0 ] ; row1LCD [ 6 ] = tempLCD [ 2 ] ; tempSend [ 0 ] = ' ' ; tempSend [ 1 ] = tempLCD [ 0 ] ; tempSend [ 3 ] = tempLCD [ 2 ] ; contSend [ 2 ] = ' ' ; contSend [ 3 ] = tempLCD [ 0 ] ; contSend [ 5 ] = tempLCD [ 2 ] ; } else { row1LCD [ 3 ] = tempLCD [ 0 ] ; row1LCD [ 4 ] = tempLCD [ 1 ] ; row1LCD [ 6 ] = tempLCD [ 3 ] ; tempSend [ 0 ] = tempLCD [ 0 ] ; tempSend [ 1 ] = tempLCD [ 1 ] ; tempSend [ 3 ] = tempLCD [ 3 ] ; contSend [ 2 ] = tempLCD [ 0 ] ; contSend [ 3 ] = tempLCD [ 1 ] ; contSend [ 5 ] = tempLCD [ 3 ] ; } }
<editor-fold defaultstate="collapsed" desc="handleADC()">
 handleADC function
<editor - fold defaultstate = " collapsed " desc = " handleADC () " > handleADC function
// Change channel to potentiometer // Reset first read flag after channel change // Change sensor flag // Back to LM35 // Get double values of temperature in C and potentiometer V // Using sprintf, convert doubles to strings and insert into display strings // Similarly for temperature