ATmega16-ad1602
源代码在线查看: main._c
#include "includes.h"
void main()
{
unsigned char *test = "The Voltage is: ";
//unsigned char *test1 = "zhm";
// unsigned char *value = "0.000 V";
Init_LCD();
init_adc();
LCD_DisplayString(1,1,test);
delay_nms(2000);
SREG |= (1
//LCD_DisplayString(2,1,temp);
//temp=ReadADC();
}
/*
unsigned int mega16_ad(void)
{
unsigned int addata;
DDRA&=~BIT(PA0);
PORTA&=~BIT(PA0);
SFIOR=0;
ADMUX=0x40;
ADCSR=0X80;
ADCSRA=(1 //ADCSR|=BIT(ADSC);
while(!ADCSR&(BIT(ADIF)));
addata=addata+ADCH*256;
ADCSR|=BIT(ADIF);
ADCSR=0x00;
return addata;
}
float j;
unsigned int count;
unsigned int Vref=50000;
unsigned char *value1 = "0.000 V";
unsigned int addata=0;
unsigned char *test = "The Voltage is: ";
unsigned char i=0;
Init_LCD();
LCD_DisplayString(1,1,test);
while(1)
{
addata = mega16_ad();
j = (float)(((float)((Vref/1024)))*addata)/1000.00;
count = j*100;
value1[0] = count /1000+0x30;
count = count %1000;
value1[2] = count /100+0x30;
count = count %100;
value1[3] = count /10 + 0x30;
value1[4] = count %10 + 0x30;
LCD_DisplayString(2,1,value1);
//delay_nms(1000);
}
*/