#include <16F877A.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=4000000)
#use rs232(baud=1200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stop=1,errors)
#use fast_io(a)
#use fast_io(b)
#define use_portb_lcd TRUE
#include <LCD.c>
#define kesme_led PIN_D0
int s=25;
int16 bilgi;
float voltaj,sicaklik;
char al;
#INT_RDA
void data_geldi(void)
{
disable_interrupts(int_rda);
al=getch();
if(al=='E')
{
al=getch();
if(al=='q')
{
s--;
}
if(al=='w')
{
s++;
}
//printf(lcd_putc,"\nSet Sicakligi %d",s);
}
output_toggle(kesme_led);
clear_interrupt(int_rda);
return;
}
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_8); //clock sinyalini 8 böl. bu hızda ADC oku
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_a(0b00001101);
output_b(0x00);
output_d(0x00);
lcd_init();
enable_interrupts(GLOBAL);
printf(lcd_putc,"\fSicaklik=");
set_adc_channel(0);
delay_us(20);
while(TRUE)
{
/*if(bit_test(*(0x0018),1))
{ //her iki tamponda doluysa hata var ! temizledik bilgi alma hatası varsa bunları imha ettik.
*(0x0018)&=0xef; *(0x0018)|=0x10; // *(0x008c)|=0x20;
enable_interrupts(INT_rda);
enable_interrupts(GLOBAL);}*/
enable_interrupts(INT_rda);
bilgi=read_adc();
voltaj=(0.0048828125*bilgi)*1000;
sicaklik=(voltaj/10);
lcd_gotoxy(10,1);
printf(lcd_putc,"%5.1f C",sicaklik);
printf(lcd_putc,"\nSet Sicakligi %d",s);
delay_ms(100);
}
}