#include <18F452.h>
#device ADC=10
#fuses HS
#use delay(clock=12000000)
#include "lcd.c"
char lcd_string[20];
void print_lcd(char *str)
{
byte cntr=0;
for (cntr=0;cntr<20;cntr++)
lcd_putc(str[cntr]);
}
void PrintVoltage1(float m_Volts)
{
lcd_gotoxy(1,1);
sprintf(lcd_string,"Voltage1 = %3.3f ",m_Volts);
print_lcd(lcd_string);
}
void PrintVoltage2(float m_Volts)
{
lcd_gotoxy(1,2);
sprintf(lcd_string,"Voltage2 = %3.3f ",m_Volts);
print_lcd(lcd_string);
}
void main (void)
{
byte m_Cntr=0;
long m_Adc_Value=0;
float m_inp=0.0;
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_CLOCK_INTERNAL );
lcd_init();
while(1)
{
set_adc_channel(0); //ADC Channel 0
delay_ms(1); //Donot remove delay
m_Adc_Value=read_adc();
delay_ms(1); //ADC needs some time for reading input so Donot remove this delay
m_inp=(m_Adc_Value/1024.0)*5.0;
PrintVoltage1(m_inp);
set_adc_channel(1); //ADC Channel 1 for reading second input
delay_ms(1); //Donot remove delay
m_Adc_Value=read_adc();
delay_ms(1); //ADC needs some time for reading input Donot remove this delay
m_inp=(m_Adc_Value/1024.0)*5.0;
PrintVoltage2(m_inp);
delay_ms(100); //This delay Can be removed
}
while(1);
}