i changed some things, but there is something wrong again....here is my code:
INCLUDE "modedefs.bas"
Flag Var Bit
Key Var Byte
Resultat Var Byte
s var byte ' KOLKO PUTI SYM NATISNAL KLAVIATURATA
W VAR WORD ' tova e nabranoto chislo ot klaviaturata
BCD1 VAR BYTE
BCD2 VAR BYTE
BCD3 VAR BYTE
BCD4 VAR BYTE
symbol Segmenti = PORTC
symbol razriad = PORTA
i Var Byte
n Var Byte
TRISA = 0
TRISB = %11110001
trisc = 0
INTCON = %10000000
W = 0
Resultat = 0
S = 0
bcd1 = 0
bcd2 = 0
BCD3 = 0
bcd4 = 0
Main:
Gosub ScanKeys
if resultat = 11 then TOGGLE PORTA.4
if resultat = 10 THEN TOGGLE PORTA.5
IF resultat = 12 then Main
SELECT CASE S
CASE 0
segmenti = $3F '0
razriad = 1 'LSDigit
GOTO MAIN
CASE 1
w= resultat
bcd1 = resultat
CASE 2
bcd2 = resultat
w = bcd1*10 + bcd2
CASE 3
bcd3= resultat
w = bcd1*100 + bcd2*10 + bcd3
CASE 4
bcd4 = resultat
w = bcd1*1000 + bcd2*100 + bcd3*10 + bcd1
CASE ELSE
S= 0
GOTO MAIN
END SELECT
gosub pokaji
ScanKeys:
Key=0
PORTB=%1000
gosub Redica
if Flag=1 then Kolona1
PORTB=%0100
gosub Redica
if Flag=1 then Kolona2
PORTB=%0010
gosub Redica
if Flag=1 then Kolona3
Resultat=12
return
Kolona1:
s = s+1
lookup Key,[1,4,7,10],Resultat
return
Kolona2:
s = s+1
lookup Key,[2,5,8,0 ],Resultat
return
Kolona3:
s = s+1
lookup Key,[3,6,9,11],Resultat
return
Redica:
Flag=1
if PORTB.4=1 then return
Key=Key+1
if PORTB.5=1 then return
Key=Key+1
if PORTB.6=1 then return
Key=Key+1
if PORTB.7=1 then return
Key=Key+1
Flag=0
return
pokaji:
For i = 0 To s
n = W Dig i
GoSub izvlechi
Next i
Return
izvlechi:
Lookup n, [$3f, $06, $5b, $4f, $66, $6d, $7d, $07, $7f, $6f], Segmenti
razriad = Dcd i
Return
end
and here is a sheme
Bookmarks