Keypad ile 4 basamaklı sayı girme

Başlatan frederic, 14 Şubat 2011, 14:38:34

izzethoca

INKEY KULLANMADIM AMA AŞAĞADAKİ GİBİ ÇALIŞTIRIYORUM
'****************************************************************
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : [İZZET AKDAĞ]                                     *
'*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 05.07.2010                                        *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
Device 16F877A
DEFINE OSC 4
OPTION_REG=1
ADCON1=7
TRISB=0
TRISA=0
PORTA=0
PORTB=0
PORTD=%11110000
PORTD=0
Dim TUS As Byte
Dim TUS1 As Byte
Dim YUZLER As Word
Dim ONLAR As Word
Dim BIRLER As Word
Dim SAYI As DWord
TEMP VAR Word

'Declare LCD_TYPE 0 'LCD tanimlaniyor
Declare LCD_DTPIN PORTB.4
Declare LCD_ENPIN PORTB.3
Declare LCD_RSPIN PORTB.2
'Declare LCD_INTERFACE 4
Declare LCD_LINES 2
Print $FE,1
DelayMS 500
BASLA:
'GoSub HESAPLA
High PORTD.0
If PORTD.4 = 1 Then TUS = 7 : GoSub hesapla :GoSub LCD_OUT : While PORTD.4 = 1 : Wend
If PORTD.5 = 1 Then TUS = 8  : GoSub hesapla :GoSub LCD_OUT : While PORTD.5 = 1 : Wend
If PORTD.6 = 1 Then TUS = 9 : GoSub hesapla :GoSub LCD_OUT : While PORTD.6 = 1 : Wend
If PORTD.7 = 1 Then TUS1 = "A" : While PORTD.7 = 1 : Wend
DelayMS 10
Low PORTD.0

High PORTD.1
If PORTD.4 = 1 Then TUS = 4  : GoSub hesapla : While PORTD.4 = 1 : Wend
If PORTD.5 = 1 Then TUS = 5 : GoSub hesapla :GoSub LCD_OUT : While PORTD.5 = 1 : Wend
If PORTD.6 = 1 Then TUS = 6 : GoSub hesapla :GoSub LCD_OUT : While PORTD.6 = 1 : Wend
If PORTD.7 = 1 Then TUS1 = "B" : While PORTD.7 = 1 : Wend
DelayMS 10
Low PORTD.1

High PORTD.2
If PORTD.4 = 1 Then TUS = 1 : GoSub hesapla : While PORTD.4 = 1 : Wend
If PORTD.5 = 1 Then TUS = 2 : GoSub hesapla :GoSub LCD_OUT : While PORTD.5 = 1 : Wend
If PORTD.6 = 1 Then TUS = 3 : GoSub hesapla :GoSub LCD_OUT : While PORTD.6 = 1 : Wend
If PORTD.7 = 1 Then TUS1 = "C" : While PORTD.7 = 1 : Wend
DelayMS 10
Low PORTD.2

High PORTD.3
If PORTD.4 = 1 Then TUS1 = "*" : SAYI =0 : TUS = 0 :Print $FE,1 : GoSub hesapla : While PORTD.4 = 1 : Wend
If PORTD.5 = 1 Then TUS = 0 : GoSub hesapla :GoSub LCD_OUT : While PORTD.5 = 1 : Wend
If PORTD.6 = 1 Then TUS1 = "#" : While PORTD.6 = 1 : Wend
If PORTD.7 = 1 Then TUS1 = "D" : While PORTD.7 = 1 : Wend
DelayMS 10
Low PORTD.3



 

GoTo BASLA 
LCD_OUT:
Print $FE,$83,"IZZET"
Print $FE,$C0,"SAYI = " ,# SAYI
Return
hesapla:
TEMP=TUS

 SAYI = (SAYI * 10) +TEMP
 TEMP=0
 If SAYI =1234 Then 
 High PORTA.0
 SAYI=0
 TUS=0
 Print $FE,1
 Print $FE,$83,"LAMBA YANIYOR"
 Print $FE,$C0,"SIFRE = " ,# SAYI
 EndIf
  If SAYI =4321 Then 
 Low PORTA.0
  SAYI=0
 TUS=0
 Print $FE,1
 Print $FE,$83,"LAMBA SONDU"
 Print $FE,$C0,"SIFRE = " ,# SAYI
 EndIf
Return


End

frederic

Teşekkürler izzet hocam,sağolun.