#include <18F4550.h>
#define VREF_A2 0x40
#fuses NOWDT,HS, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#include <flex_lcd.c>
#include <MCP3208.c>
void main(void)
{
unsigned long int adc_ham;
float a;
set_tris_d(0x00);
set_tris_b(0x40);
output_d(0x00);
output_b(0x00);
adc_init();
lcd_init();
delay_ms(100);
printf(lcd_putc,"\f");
lcd_gotoxy(3,1);
printf(lcd_putc,"harici adc");
lcd_gotoxy(1,2);
printf(lcd_putc,"PIC 18 F 4550");
delay_ms(1000);
printf(lcd_putc,"\f");
char volt[24];
for(;;){
adc_ham=read_analog_mcp(0,1);//1.kanal single modda okuma.0-> diferansiyel mod
// adc_ham=read_analog(0);
a=1000*(float)adc_ham/13104;
convert_to_volts( adc_ham,volt);
//printf(lcd_putc,"\f%s mV", volt);
lcd_init();
delay_ms(10);
printf(lcd_putc,"\f");
lcd_gotoxy(7,1);
printf(lcd_putc,"NF 12");
lcd_gotoxy(1,2);
printf(lcd_putc,"\f%f mV", a);
delay_ms(50);
}
}