#include <16f628a.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay (clock=4000000)
#use fast_io(a)
#use fast_io(b)
#define use_portb_lcd TRUE //LCD PORTB YE BAĞLI
#include <lcd.c>
unsigned char kontrol=0;
unsigned char sonuc[]=" ";
unsigned int CX;
float pi=3.14159,r=0.0811;
//***************ANA PROGRAM*******************
void main()
{
setup_psp(PSP_DİSABLED);
setup_timer_1(T1_DİSABLED);
setup_timer_2(T2_DİSABLED,0,1);
setup_adc_port(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_CCP1(CCP_OFF);
setup_CCP2(CCP2_OFF);
set_tris_a(0xFF);
set_tris_b(0x00);
output_a(0x00);
output_b(0x00);
lcd_init(); //LCD Yİ HAZIRLA
lcd_clear(); //LCD Yİ TEMİZLE ??????
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_8); //T0 AYARLAMALARI
set_timer0(131); // T0 DEĞERİ ATAMASI 256-131=125
while(SW==1); //GİRİŞ 1 İSE BEKLE
while(kontrol==0)
{
if(SW==1)
break;}
goto LCD_YAZ();
}
//*************LCD ALT PROGRAMI*************
void LCD_YAZ()
{
float hiz;
unsigned int hiz2;
lcd_clear(); //???????????
hiz=(2*pi*r*3600)/CX; //KM/H CİNSİNDEN HİZ
hiz2=(int)hiz; //???????????HIZI HESAPLA
lcd_send_byte(0,0x0d); //LCD YE KOMUT GÖNDERİYOR.İMLEÇ YANIP SÖNSÜN
printf(lcd_putc,"\f zAc HIZ GOSTERGESI");//LCD YE VERİ GÖNDER
delay_ms(1000); //1s gecikme
lcd_gotoxy(1,2); //1. SUTUN 2. SATIRA KONUMLANDIR
if(kontrol==0)
{
printf(lcd_putc,"\f HIZ=%d",sonuc);//sonuc yerine hiz2 yaz
}
else
{
printf(lcd_putc,"\f HIZ=0"
; //BİSİKLET DURUYORSA HIZ=0 YAZDIR
}
}
//*************T0 KESME ALT PROGRAMI*******************
#int_timer0 //T0 KESMESİ
void timer0_kesme()
{
CX++;
if(CX>10000)kontrol=1;
TOIF=0; //??????BAYRAK TEMİZLEME
set_timer0(131);
}