@ DEVICE pic16F877, HS_OSC,WDT_OFF,PWRT_ON,CPD_OFF
@ DEVICE pic16F877, LVP_OFF,PROTECT_OFF,BOD_OFF
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTD
Define LCD_RSBIT 2
Define LCD_EREG PORTD
Define LCD_EBIT 3
'###############################################
'CMCON=7 'komparatör iptal
OPTION_REG.7=0 'Dahili pull-up lar aktif
LCDOUT $FE,1
'###############################################
ESKI var BYTE
YENI var BYTE
YON var BYTE
SAY var word
SAYI VAR word
CLEAR
'###############################################
SAYICI:
ESKI=PORTD & %00000011 'oku PORTD.0 PORTD.1
PAUSE 2
YENI=PORTD & %00000011 'oku PORTD.0 PORTD.1
IF ESKI=YENI then
GOTO SAYICI
ENDIF
ESKI=ESKI & %00000001 'sadece PORTD.0 ı oku
YENI=YENI>>1 'sadece PORTD.1 ı oku
YON=ESKI^YENI 'PORTD.0 XOR PORTD.1
IF YON=1 then
SAY=SAY+1 'yukarı
ELSE
SAY=SAY-1 'aşağı
ENDIF
LCDOUT $FE,$80," SAYI : ",DEC5 SAY
GOTO SAYICI