Implementing 12 button keypad into circuit

Thread Starter

mechgirl

Joined Nov 8, 2010
3
Hello,

For a school project my group is making an automatic car starter. We are trying to implement a 12 button keypad into our controller for the user to enter a passcode. We are working with a PIC 16F88 micro controller
We have a LCD interfaced to the PIC through an EDE 702 chip and know that the LCD works because it displays the information we want it to.
We are having problems with our 12 key input though.
We are using a 12 key input that is connected to an EDE 1144 chip, of which is connected to the PIC as follows:
From EDE 1144 to PIC 16F88
XMIT to PortB.0
Valid to PortB.1
When the system starts up our "test" mode works properly, but when we click the "1" or "2" key on the 12 key input, the system doesn't change to the next stage in the code. We are using PIC Basic Pro to program the 16F88. I think it is a coding problem as our circuit is setup properly according to the data sheets. Any help would be appreciated. Thanks!

Here is our program:
'Identify and set internal clock speed
Define OSC 8
OSCCON.4=1
OSCCON.5=1
OSCCON.6=1

CMCON.0 = 1
CMCON.1 = 1
CMCON.2 = 1
CVRCON.6 = 0
CVRCON.7 = 0

'Turn off A/D converter
ANSEL=0

I Var byte
key_serial Var PortB.0
green Var PortB.2
red Var PortB.3
key_value Var byte

key_mode Con 0
key_1 Con $30
key_2 Con $31
key_3 Con $32
key_4 Con $34
key_5 Con $35
key_6 Con $36
key_7 Con $38
key_8 Con $39
key_9 Con $41
key_star Con $43
key_0 Con $44
key_pound Con $45
Pause 100

Low green
Pause 100
Low red
Pause 100
Pause 4000
'Set loop counter to 0
I=0

test:
'Test to make sure system is working
SEROUT PortA.0, 0,[$FE, 1, "**Testing**"]
Pause 100
High green
PAUSE 1000
Low green
PAUSE 100
High red
PAUSE 1000
Low red
PAUSE 100
SEROUT PortA.0, 0,[$FE, 1, "*System Ready*"]
PAUSE 1000
Gosub main_menu
Gosub loop

'Main program loop
loop:
Serin key_serial, key_mode, key_value
IF(key_value = key_1) Then
SEROUT PortA.0, 0,[$FE, 1, "Enter Passcode"]
SEROUT PortA.0, 0,[$FE, $C0, "* or #: Main Menu"]
Gosub code
ELSE
IF(key_value = key_2) Then
Gosub test
ENDIF : ENDIF
Gosub loop
END

main_menu:
SEROUT PortA.0, 0,[$FE, 1, "Main Menu:"]
SEROUT PortA.0, 0,[$FE, $C0, "1:Start, 2:Test"]
Return

code:
Serin key_serial, key_mode, key_value
If(key_value = key_1) Then
Gosub program
Else
If(key_value = key_2) Then
Gosub wrong_passcode
Else
If(key_value = key_3) Then
Gosub wrong_passcode
Else
If(key_value = key_4) Then
Gosub wrong_passcode
Else
If(key_value = key_5) Then
Gosub wrong_passcode
Else
If(key_value = key_6) Then
Gosub wrong_passcode
Else
If(key_value = key_7) Then
Gosub wrong_passcode
Else
If(key_value = key_8) Then
Gosub wrong_passcode
Else
If(key_value = key_9) Then
Gosub wrong_passcode
Else
If(key_value = key_0) Then
Gosub wrong_passcode
Else
If(key_value = key_star) Then
Gosub main_menu
Else
If(key_value = key_pound) Then
Gosub main_menu
Endif : Endif : Endif : Endif : Endif : Endif
Endif : Endif : Endif : Endif : Endif : Endif
Gosub code
End


wrong_passcode:
SEROUT PortA.0, 0,[$FE, 1, "Wrong Passcode"]
Pause 1000
Gosub code

program:
Low green 'Green led set to off
Low red 'Red led set to off

WHILE(PORTA.2==1)
'If there is no system response within approximatly 10 seconds, turn on red led
IF(I==10)THEN
SEROUT PortA.0, 0,[$FE, 1, "System Timed Out"]
Pause 10
High red
PAUSE 1000
Else
I=I+1
IF(PORTA.3==0)Then
SEROUT PortA.0, 0,[$FE, 1, "System Running"]
Pause 10
High green
PAUSE 1000
Low green
PAUSE 100
Endif
While(PortA.3==1)
SEROUT PortA.0, 0,[$FE, 1, "*System Error*"]
Pause 10
High red
PAUSE 100
Wend
PAUSE 100
ENDIF
WEND

GOTO program
Return
END
 
Top