Page 1 of 2

Basic Keypad - LCD Four Digit Door Lock.

Posted: Sun May 23, 2010 10:09 am
by medelec35
Have adapted the Flowcode I posted here: http://matrixmultimedia.com/mmforums/vi ... f=5&t=7140 to create a basic 4 digit code door lock.

Here is a challenge: See if you can edit the Flowcode so If you make a mistake in entering 1 digit. you can re-enter that digit.
By following and learning how a flowcode routine works, then altering to acheive desired results, I beleive is a great way of learning!

I have deliberately created a Flowcode in which re-entering a digit is easily achievable.
For Beginners: See how arrays are used, and how several arrays are converted to an integer and compared with another integer.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Wed Jun 16, 2010 7:17 pm
by Spanish_dude
I'm using flowcode v3 and I can't open the file so it would be great if you could make an v3 file or attach the C code.

Thx anyway for the program :mrgreen:

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Wed Jun 16, 2010 9:34 pm
by medelec35
I wil create a V3 version and hopfully will post it tomorrow (Thursday EVE).
Here is C file.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Jun 19, 2010 9:42 am
by medelec35
Sorry been a bit busy. So here is V3 version of LCD Four Digit Lock.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Jun 19, 2010 5:27 pm
by Spanish_dude
Hi medelec35,

Thx for the flowcode file.

I just have one thing to say.

Why are you using an array to store the value of the keypad ?

You could do it like this :

Code: Select all

//...
short private_code = 1234;
short user_code = 0;
char key = 0;
//...
//if key is pressed
user_code *= 10 + key;
//...
Regards,

Nicolas L.F.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Jun 19, 2010 7:02 pm
by medelec35
Hello Nicolas.
You are welcome.
The reason for storing value of keypad is because a Flowcode user wanted to press several keys e.g 1 2 3, and convert the keypad presses into an integer i.e one hundred and twenty three. See http://www.matrixmultimedia.com/mmforum ... f=5&t=7140. Since I already had that flowcode stored, I thought I would use it to make an electronic door lock.
Also keypad was stored as an array, so string conversion is not required. Thus reducing the overall size and memory usage. Also if you store as an array, you can easily manipulate and say delete the 2nd from last entry for correction.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sun Jun 20, 2010 9:53 pm
by Spanish_dude
Hi medelec,

I'm not sure about reducing the size of the memory using an array.
If I'm correct, an integer is 4 bytes and a char is 1 byte (so an array of 4 chars = 4 bytes).
Only if you are willing to use a password with 3 or less digits, it will reduce the size of the memory (a little :P).

But I do see the point of using an array.
-It ts easy to change each variable in array
-Because an integer only goes to ~32000 your password can not have more than 4 digits. With an array of chars you could have (much) more than 4 digits.

Thx anyway :mrgreen:

Nicolas L.F.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sun Jun 20, 2010 10:28 pm
by medelec35
I believe the size reduction due to the fact that string conversion is not required. So that negates the requirement of both string variables and integers. But I could be wrong.
As using integer opposed to arrays. Yes you are correct, that would simplify compared to arrays. As previously stated This article was derived from another post, for someone who wanted to store each key-press, and use them to form a function. Also someone else wanted to store and compare a number with more than 5 digits, so its back to string or arrays.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Apr 07, 2012 10:05 am
by donald
Hi,
How do I change the code of the keyboard ?
It can give you an example flowchart ?

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Apr 07, 2012 10:33 am
by medelec35
Hi donald,
When you open flowchart, you will see:
Change code.png
(9.6 KiB) Downloaded 18512 times
so to change code just alter the 1234

If you have got EEPROM on your target device, then you could have a master key or current pw and to change pw by entering new pw with keypad.
Then new pw can be saved on EEPROM
The reason for a master key is the pw may have been changed, but new pw could be forgotten.
Master key can be left unchanged.

I will probably alter flowchart to do that, when I get some time spare on my hands.

Martin

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Apr 07, 2012 10:49 am
by donald
I understand a bit, but for me it is hard, because I don't know what to write and to add to flowchart.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Tue Apr 10, 2012 10:30 am
by Benj
Hi Donald,

There is a free "introduction to micros" course available from here designed to help get you started with Flowcode and programming.

http://www.matrixmultimedia.com/lc_index.php?p=24

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Sat Apr 14, 2012 7:51 am
by donald
Hi everybody,
Thank You Martin and Ben, I have added to the bill Martin a protection for the three tests wrong to enter the code.
In the first two codes wrong the system will generate a warning signal and short acoustic optical (200ms), on the third
attempt will generate an alarm signal for 5s or more. I have a question, where I had to look to learn about some
instructions that I must write to them, for example:

Result = degcalc[0]*1000+degcalc[1]*100+degcalc[2]*10+degcalc[3]

In addition to Flowcode, must learn a different development environment ?
Thank you very much !

Sam

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Oct 18, 2013 11:10 am
by iron_zombie
Hi.

Thanks to the people doing the programme. Is it possible to do one so that multiple passcodes could be entered (approx 20)?

Would someone be able to do that?

Thanks

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Oct 18, 2013 7:20 pm
by dazz
Hi iron zombie

Have a go yourself and when you get stuck post a flowchart and someone will help you out, also heavily comment you flowchart if you can as it will also help others to help you if they can see what your trying to do

Regards
Dazz

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Tue Oct 22, 2013 7:57 pm
by iron_zombie
Hi, I take it it's not as simple as just modifying the existing programme posted is it? I tried just adding more pass codes to it but when I do that, only the last pass code entered unlocks the door.

My programming knowledge is basically non-existent so I wouldn't know where to start really to do my own programme.

Thanks for your response.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Nov 15, 2013 11:12 am
by iron_zombie
Hi, I've had a go at editing the programme with more than one access code by using a macros however all it does is register the first macro. So if I try entering the other codes in the other three macros (e.g. 2345, 3456 or 4567) it still says wrong code. Can anyone help?

Also I doubt using the macros is the most efficient use of the chip either as it will likely take up a lot of memory. Is it possible to have multiple pass codes in some sort of array and then the programme calls on that array to allow entry?

Thanks.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Nov 15, 2013 12:05 pm
by iron_zombie
Apologies for the double post. I've worked on it a bit more. I've managed to sort an array out and have it so that there are twenty possible numbers plus another ten left to enable them to be edited at a later date if needed (these 10 are entered as 0000 which i've set to keep the door locked).

My problem now is though that the last two real pass codes (i.e. Code[18] and Code [19] in the array) say wrong code when entered. All the other passcodes (Code[0] to Code[17]) work, but for some reason Code[18] and Code[19] don't.

Anyone know where I'm going wrong?

I forgot to mention I'm using flowcode 5 by the way.

Thanks

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Nov 15, 2013 12:06 pm
by Benj
Hello,

The macros have while 1 loops which means that they will never exit so your program will only ever stay in macro 1.

Here is a version of the program that uses an array to store the keys, not tested it but it should work.
Door Lock 16F877A 4 pass codes.fcf
(18.98 KiB) Downloaded 709 times

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Nov 15, 2013 12:11 pm
by Benj
Anyone know where I'm going wrong?
Have a look at my example, I use a loop rather then the large if statement you have. My guess is that the loop approach will be more reliable for lots of keys and allows you to easily see which code provided the unlock.

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Nov 15, 2013 2:33 pm
by medelec35
Not seen Bens example, so this maybe a similar approach.
Sorry if it is Ben, as its the way I would tackle this issue.

Martin

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Fri Nov 15, 2013 7:33 pm
by medelec35
Just had a look at Ben's example, and mine is totally different.
With the flowchart on my above post, its possible to have up to 255 different past codes by changing:

(Count = 30) || (Result = Code[Count])
to
(Count = 254) || (Result = Code[Count])

Also you will need to increase size of array of course :)

Martin

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Tue Dec 10, 2013 8:27 pm
by obertelli7
Hi
I have a similar program to this, however I have installed a switch before a code can be entered.
I'm having problems in getting the switch to reset to a low state again without manually pressing the switch again. This enables the user to enter another code.
Is there a way to automatically reset this in the program so that the user can't enter multiple codes without pressing the switch again?
Any help would be great,
Thanks!

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Tue Dec 10, 2013 9:44 pm
by medelec35
Hi obertelli7,
Welcome ot the forums.
If you would like to post your flowchart, I can take a look at it for you.

Martin

Re: Basic Keypad - LCD Four Digit Door Lock.

Posted: Wed Dec 11, 2013 1:19 pm
by obertelli7
For some reason I can't attach any files or images?