int main(void)
{
int adc_value1=0;
LCD_Init(2,16);
adc_init();
LCD_Clear();
LCD_GoToXY(0,0);
LCD_DisplayString(" G-Electron");
_delay_ms(1000);
//
while(1)
{
adc_value1 = volt_read_disply();
LCD_GoToLine(1);
LCD_DisplayString(" Volt : ");
LCD_Printf("%d",adc_value1);
LCD_DisplayString("V");
_delay_ms(1300);
}
}
int volt_read_disply()
{ int i,adc_value[40]={0}; int temp =0, adc=0;
adc_init();
for(i=0; i<=40;i++) // samples taking from 41 times 9.4milli second taken about on complte half cycle
{
adc_value[i] = read_adc(0); // reading voltage
}
temp = adc_value[0];
for(i=0; i<=40; i++)
{
if(temp<adc_value[i])
temp=adc_value[i];
}
adc=temp;
return (adc*0.224828935);
}