dear sir
the program listed below, i write it with proton ide, i check the connection and every think fine. thanks
Device = 16F877A
XTAL 4
Declare LCD_TYPE 0
Declare LCD_DTPIN PORTD.4
Declare LCD_ENPIN PORTD.3
Declare LCD_INTERFACE 4
Declare LCD_RSPIN PORTD.2
' Define program variables
Dim Col As Byte
Dim Row As Byte
Dim Key As Byte
Dim k[4] As Byte
Dim ikey As Byte
Dim ti As Word
Dim tii As Float
OPTION_REG.7 = 0
Output PORTC.0
DelayMS 100
Print 254,1, "In Freq. in Hz"
Print At 2,1
k[0] = 0
k[1] = 0
k[2] = 0
k[3] = 0
Loop2: GoSub Getkey
If Key = 1 Then
k[ikey] = "1"
Print "1"
Inc ikey
End If
If Key = 2 Then
k[ikey] = "2"
Print "2"
Inc ikey
End If
If Key = 3 Then
k[ikey] = "3"
Print "3"
Inc ikey
End If
If Key = 4 Then
k[ikey] = "4"
Print "4"
Inc ikey
End If
If Key = 5 Then
k[ikey] = "5"
Print "5"
Inc ikey
End If
If Key = 6 Then
k[ikey] = "6"
Print "6"
Inc ikey
End If
If Key = 7 Then
k[ikey] = "7"
Print "7"
Inc ikey
End If
If Key = 8 Then
k[ikey] = "8"
Print "8"
Inc ikey
End If
If Key = 9 Then
k[ikey] = "9"
Print "9"
Inc ikey
End If
If Key = 11 Then
k[ikey] = "0"
Print "0"
Inc ikey
End If
If Key = 12 Then
ti=Val(k,Dec)
Print 254,1, "frequency: ",#ti," Hz"
tii = (1/ti) * 500
loop:
PORTC.0 = 1
DelayMS tii
PORTC.0 = 0
DelayMS tii
If PORTB.7 = 0 Then
Print 254,1, "In Freq. in Hz"
Print At 2,1
k[0] = 0
k[1] = 0
k[2] = 0
k[3] = 0
tii = 0
ti = 0
ikey = 0
GoTo Loop2
End If
GoTo loop
End If
GoTo Loop2
Getkey:
DelayMS 50
Getkeyu:
' Wait for all keys up
PORTB = 0
TRISB = $F0
If (PORTB >> 4) <> $0F Then Getkeyu
DelayMS 50
Getkeyp:
For Col = 0 To 3
PORTB = 0
TRISB = (DCD Col) ^ $FF
Row = PORTB >> 4
If Row <> $0F Then Gotkey
Next
GoTo Getkeyp
Gotkey:
Key = (Col * 3) + (NCD (Row ^ $0F))
Return
Label:
End