void Adc_Init(void)
{
// PORTA =0x00;
// DDRA =0x00;
ADMUX = (1<<REFS1)|(1<<REFS0);//选择第一通道ADC0,内部REF(2.56V)
ADCSRA = (1<<ADEN)|(1<<ADPS1);//16M64分频,125k速率,启动AD转换器
_delay_ms(10);//延迟100ms等待系统稳定后读取数据
}
uint16_t read_adc(uint8_t adc_chanel)
{
unsigned int adc;
ADMUX |= (0XC0|adc_chanel); //选择转换通道
ADCSRA |= (1<<ADSC); //开始转换
while(!(ADCSRA & (1 << ADIF))); //等待结束
ADCSRA |= (1<<ADIF); //清除标志
adc=ADCL+ADCH*256;
return(adc); //ADC=ADCH:ADCL
}