Storing a user defined PIN in a keypad lock

aeg

New Member
One of my students is building an electronic lock that features a 4 x 3 matrix keypad, a PICAXE (of whatever type is needed) and a servo motor output.

He would like be able to allow the user to redefine the 4-digit PIN without having to edit the program code each time and download it to the PIC. Can anyone suggest the easiest/best way of doing this or point me to documentation where I might find a solution?

AEG
 

goom

Senior Member
Perhaps you could trigger an interrupt by pushing a "Change PIN" button. In the interrupt routine you could prompt for a master password (otherwise anyone could change the PIN), then prompt for a new PIN which could be stored permanently on the PICAXE using "writemem".
Hope this helps
 

aeg

New Member
Perhaps you could trigger an interrupt by pushing a "Change PIN" button. In the interrupt routine you could prompt for a master password (otherwise anyone could change the PIN), then prompt for a new PIN which could be stored permanently on the PICAXE using "writemem".
Hope this helps

That's a very helpful suggestion; thank you.
I've not used "writemem" before but I've checked the manual and it looks promising. I've also looked at "write" and wonder whether that would be a suitable alternative. It looks very similar and according to the manual, "write" can be used with any PIC, whereas "writemem" can only be used with the 28A. Is there a significant difference between the two commands?

AEG
 

aeg

New Member
A key operated switch (saves the extra security option) and save the code as a word.
Sorry Rick, I'm not quite sure what you mean by that.
Are you suggesting the use of a key operated switch to validate the user's authority to change the PIN and then to save it with the "write" or "writemem" command?

AEG
 

leftyretro

New Member
I would implement two codes into the program, the active PIN code and a code that allows changing the PIN code. If the active PIN code is entered then the device would activate. If the change PIN code is entered then the PICAXE would accept the new PIN code entered via the keypad and store this new PIN code as the now new active PIN code. Store the new active pin in the memory with write or writemem (whichever works for your device) in case a power reset occurs. That way no new switches are needed. You might consider an LED that flashes while waiting for a new PIN number.

Lefty
 

Matt_C

Member
I've just looked at page 174 & 175 of manual2 and it looks like 'WRITE' can be used on the entire range of PICAXE but 'WRITEMEM' can only be used on a 28A PICAXE. I suggest you study these 2 pages.

Have a search on the forum as I recently found a thread that explains how to use a 4x3 matrix keypad via a resistor divider set-up so only 1 wire is needed on the ADC for key input.

I would use an 08M PICAXE with the keypad on the ADC.
Let the user set the pin length from 4 to 8 digits.
Enter PIN followed by say the '*' key then the PICAXE would test and accept or reject the code.
After 3 wrong attempts you could put a delay of a few minutes before anymore attempts can be accepted. You could also have an alarm after X amounts of attempts.
To change the PIN you could enter PIN followed but '#' key directly followed by the new PIN followed by '*' key.
If the first PIN is correct then change the PIN to the one that was entered after the '#' key.
I would suggest a physical key just to be safe from loss of power/fault or data corruption.
 

Katzenjammer

New Member
Rather than having a master pw, which could be compromised, I'd suggest using the existing pw as authority for entering a new one. So if you know the old one, you can change it.

Your student could also avoid the 'change pw' pin by adding some sequence to the end of the pw, e.g., 'fratz' is the get-in pw, whereas 'fratz999' allows change. Then, if the new get-in is 'foobar', the new change-pw becomes 'foobar999'. It doesn't matter whether the 999 is generally known since it's merely a shunt.

(I should have read all the replies before writing mine, since I'm suggesting the same thing Matt and Lefty have done. Oh well, extra support. :D )
 
Last edited:

aeg

New Member
Many thanks to all who have made suggestions: all very helpful, both individually and collectively.

Jon Henry is right to assume that there is no LCD in the system, and I thank him for the link that takes me to a Breach Alarm System containing the code I'm looking for! With this and the other suggestions it appears that we should be able to put together the ideal solution.

Thanks again,
AEG
 

Rickharris

Senior Member
Sorry Rick, I'm not quite sure what you mean by that.
Are you suggesting the use of a key operated switch to validate the user's authority to change the PIN and then to save it with the "write" or "writemem" command?

AEG
Yes it makes the validation a single input saving the new code has to depend on how big it is bit writing it to a given memory location is perhaps the easiest.
 

Cnoble5

New Member
I've been lurking around the forums for a while now, and I'm about to attempt my own version of this project.

Possible features may include:

- Key Switch to disable lock and enable PIN changing.
- LED Display to display commands etc (May replace LED)
- Bi Colour LED indicating status of lock
(Red = Locked, Green = Unlocked, Flashing = PIN Setup mode)
- Lock consisting of 6v Solenoid Bolt

Basically I was just wondering if anyone had any advice based on previous experience seeing as this will be my first serious project involving PICAXE.

I also wanted to investigate the possibility of using 12v Door Strike Plates in place of the solenoid bolt, but I don't know how simple this would be?
 
Last edited:

Andrew Cowan

Senior Member
- Bi Colour LED indicating status of lock
(Red = Locked, Green = Unlocked, Flashing = PIN Setup mode)
To save the trouble of having to flash an LED (very hard as a background task), why not use a tri colour LED and have red = locked, green = unlocked, and yellow = pin being entered or pin being set?

Andrew
 

Cnoble5

New Member
Thats a good idea, and one I admit I hadn't even considered.

After having a look at the lock kit, it does indeed seem a good place to start, with the possibility of adding further functionality later.

Thanks for the help.
 
Top