ADC initialization:
ADMUX? =( 1 & lt; & ltref s0)|(ADC _ mux & amp; 0x0f); //Select internal AVCC as reference, and REFS 1 and REFS0=0 1 AVCC as reference voltage.
ACSR =( 1 & lt; & ltACD); //Turn off the analog comparator
ADCSRA =( 1 & lt; & ltADEN)|( 1 & lt; & ltADSC)|( 1 & lt; & ltADIE)|( 1 & lt; & ltadps 2)|( 1 & lt; & ltADPS 1)? ; //64 frequency division? */
ADMUX = 0X40? //Reference voltage =AVCC? Conversion result is right-aligned, AD channel 0.
ADCSRA = 0X85? //AD enabled, conversion clock select bit =FOSC/32, single conversion
This is a hardware circuit.
ADC reads data:
ADCSRA | = 0x40// Start conversion?
What time? (ADCSRA & amp0x 40); //Wait for the conversion to end?
l = ADCL; ? //Low data? , pay attention to read the low position first.
h = ADCH; ? //High data?
h & lt& lt=8; //Merge data
H is an unsigned integer, which is the final voltage value.