Reading analog pin
i'm trying understand piece of code written at90usb avr:
i know it's doing read on analog pin (which used calculate battery voltage level), can't figure out which. being set admux line?
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").
you can read in datasheet (the full datasheet, not "summary").
Arduino Forum > Using Arduino > Programming Questions > Reading analog pin
arduino
Comments
Post a Comment