I got a couple of questions to ask some of you very smart people here.
I'm testing a program for scanning a 3x4 keypad and a yellow LED is supposed to light up whenever a key is pressed. The problem is the LED only lights up if i press keys from the 2nd and 3rd column, it doesn't give any response if i press keys from the 1st column (1,4,7,*).
1st column - RB0
2nd column - RB1
3rd column - RB2
1st row - RB3
2nd row - RB4
3rd row - RB5
4th row - RB6
2. And how do i set up an administrative password where the password is already in EEPROM location 0 when the system starts up? Do i use the DATA function? If the admin password is 1234, the user has to key in 1234 then only a green LED will light up.
DEFINE LOADER_USED 1
i VAR byte
col VAR byte
row VAR byte
num VAR byte
PIN VAR byte[4]
ADMIN VAR byte[4]
GREEN VAR PORTA.2
YELLOW VAR PORTA.1
BUZZER VAR PORTA.3
OPTION_REG.7 = 0
DATA 0,..............??????? I don't know how to write this part!!!
SETPIN:
SETPIN:
i = 0 WHILE i<4 PIN = 0 GOSUB KEYPAD LET PIN = num i = i + 1
WEND
CHKAMD:
WRITE 1, PIN
PAUSE 200
READ 0, ADMIN
PAUSE 200
IF PIN4 = ADMIN THEN
GREEN = 1
END
ELSE
GOTO SETPIN
ENDIF
KEYPAD:
PAUSE 50
NO_KEY:
TRISB = %01111000
PORTB = 0
IF ((PORTB >> 3)!= %1111)THEN GOTO NO_KEY
PAUSE 50
GOTKEY:
FOR col = 0 to 2
row = 0 TRISB = (dcd col)^%11111111
PORTB = 1
row = PORTB>>3
IF (row!= %1111)THEN CAL_NUM
NEXT col
GOTO GOTKEY
CAL_NUM:
YELLOW = 1
SOUND BUZZER,[100,10]
PAUSE 500
YELLOW = 0
num = (col*3) + (ncd (row^$F))
RETURN
Please tell me what changes do i have to make to this program.
Thanks a million!!!
Bookmarks