Reading analog pin


i'm trying understand piece of code written at90usb avr:
code: [select]
int16_t analogread(void)
{
    uint8_t low;
    adcsrb = 0;
    admux  = 0xc0;                // mux input
    adcsra = (1<<aden) | ((1<<adps2) | (1<<adps1)) | (1<<adsc);  // conversion
    while (adcsra & (1<<adsc)) ;
    low    = adcl;                // read lsb first
    return (adch << 8) | low;     // read msb once!
}


i know it's doing read on analog pin (which used calculate battery voltage level), can't figure out which.  being set admux line?

yes, admux register selects analog input.
you can read in datasheet (the full datasheet, not "summary").


Arduino Forum > Using Arduino > Programming Questions > Reading analog pin


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62