0
uint read_adc(uchar adc_input)

{

ADMUX=adc_input | (0x00 & 0xff);

delay_us(10);

ADCSRA|=0x40;     //START THE CONVERSION

while ((ADCSRA & 0x10)==0);     // wait for the conversion to complete

ADCSRA|=0x10;   //clear the ADC flag

return ADCW;

}

Q: Whats the meaning of "ADMUX=adc_input | (0x00 & 0xff)" ? which input channel we have selected here ?

Paul R
  • 208,748
  • 37
  • 389
  • 560
Komal
  • 85
  • 1
  • 2
  • 7

1 Answers1

1

0x00 & 0xFF is nonsensical, as it will always evaluate to 0. You can rewrite that line as ADCMUX = adc_input;

Your channel selected will be the value stored in adc_input

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82