Re: KeyPad Lock made from a 16F84A trouble
From: Michael (NoSpam_at_att.net)
Date: 07/16/04
- Next message: Winfield Hill : "Re: High voltage switching power supply"
- Previous message: Liquid Sunshine: "Re: GROUP BUY: Nichia 365nm (UV) 100mw (optical power!) LED"
- In reply to: Cason: "KeyPad Lock made from a 16F84A trouble"
- Next in thread: John Jardine: "Re: KeyPad Lock made from a 16F84A trouble"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Jul 2004 11:56:11 GMT
Cason wrote:
>
> I just recently got into programming PIC chips and have started a new
> project. A key pad combination controlled lock. I have a keypad with the
> numbers 0-6 on it and an enter button. The idea is to enter the right
> combination, press enter and then a signal will be sent off one of the I/O
> pins to unlock the lock.
>
> The trouble is, with the clock speed so high, I have to make sure that after
> one presses the key it does not register that key again if they dont get
> their finger off it fast enough. I wanted to make the device programmable so
> I didnt want to hardcode any of the numbers in which is where I run into
> trouble. I didnt explain my problem well but I just cant see what direction
> to go from here, It probably makes more sense in the code.....The commented
> part is the part I need help with......
> If there was a way to compare numbers or AND bits or OR bit instead of bytes
> I think I could do it....Any suggestions?
>
> ;Constants
> STATUS equ 03h
> TRISA equ 85h
> TRISB equ 86h
> PORTA equ 05h
> PORTB equ 06h
> NUM1 equ 0Dh ;NUM1-6 are where the combo is stored
> NUM2 equ 0Eh
> NUM3 equ 0Fh
> NUM4 equ 10h
> NUM5 equ 11h
> FLAG equ 13h ;Not quite sure what to do with this yet...Im sure Ill need
> it though
> COUNT equ ;Used for delay subroutine
>
> ;Temp stuff just to give NUM1-6 a combo which is 1-2-3-4-5
> movlw 01h
> movwf NUM1
> movlw 02h
> movwf NUM2
> movlw 03h
> movwf NUM3
> movlw 04h
> movwf NUM4
> movlw 05h
> movwf NUM5
>
> ;Setup ports
> bsf STATUS,5
> movlw 01h
> movwf TRISA
> movlw b'11111111'
> movwf TRISB
> bcf STATUS,5
>
> ;Main Loop
> movlw 00h
> movwf FLAG
> State1 btfss PORTB,NUM1 ;<----Is this valid code? I didnt know if the
> NUM1 part is valid...
> goto State1
> call Delay
> State2 ;make sure no buttons are pressed
> ;If button other than value in NUM2 is pressed goto State1
> ;If button associated with NUM2 is pressed goto State3
> State3
> State4
> State5
>
> Delay
> ;just wait....I dont need help with this....
Regarding label "State1", yes, that code is perfectly legal. But I
think it doesn't do what you intend. You have NUM1 equated to 0x0D, a
atorage location for one of your variables. The code in question tests
bit 0x0D of PortB; bit thirteen does not exist on an 8-bit port.
Might be other problems with your code. I stopped checking at "State1".
The speed of your micro isn't a problem as far as using a keyboard.
Debounce the keys, either in hardware or in software, and when your code
detects a key "down" it should wait for it to go "up" again and not
process any further key presses until that key is "up" again.
- Next message: Winfield Hill : "Re: High voltage switching power supply"
- Previous message: Liquid Sunshine: "Re: GROUP BUY: Nichia 365nm (UV) 100mw (optical power!) LED"
- In reply to: Cason: "KeyPad Lock made from a 16F84A trouble"
- Next in thread: John Jardine: "Re: KeyPad Lock made from a 16F84A trouble"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|