Basic Keypad - LCD Four Digit Door Lock.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Basic Keypad - LCD Four Digit Door Lock.
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.
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.
- Attachments
-
- Door Lock.fcf
- (14 KiB) Downloaded 1848 times
Martin
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
Thx anyway for the program
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
I wil create a V3 version and hopfully will post it tomorrow (Thursday EVE).
Here is C file.
Here is C file.
- Attachments
-
- Door Lock.c
- (21.68 KiB) Downloaded 993 times
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
Sorry been a bit busy. So here is V3 version of LCD Four Digit Lock.
- Attachments
-
- Door Lock for FlowcodeV3.fcf
- (12 KiB) Downloaded 1184 times
Martin
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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 :
Regards,
Nicolas L.F.
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;
//...
Nicolas L.F.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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.
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.
Martin
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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 ).
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
Nicolas L.F.
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 ).
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
Nicolas L.F.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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.
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.
Martin
Re: Basic Keypad - LCD Four Digit Door Lock.
Hi,
How do I change the code of the keyboard ?
It can give you an example flowchart ?
How do I change the code of the keyboard ?
It can give you an example flowchart ?
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
Hi donald,
When you open flowchart, you will see: 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
When you open flowchart, you will see: 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
Martin
Re: Basic Keypad - LCD Four Digit Door Lock.
I understand a bit, but for me it is hard, because I don't know what to write and to add to flowchart.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Basic Keypad - LCD Four Digit Door Lock.
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
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
-
- Posts: 4
- Joined: Fri Oct 18, 2013 11:04 am
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
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
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
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
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 4
- Joined: Fri Oct 18, 2013 11:04 am
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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.
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.
-
- Posts: 4
- Joined: Fri Oct 18, 2013 11:04 am
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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.
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.
- Attachments
-
- Door Lock 16F877A 4 pass code macro.fcf
- (60.21 KiB) Downloaded 566 times
-
- Posts: 4
- Joined: Fri Oct 18, 2013 11:04 am
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
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
- Attachments
-
- Door Lock 16F877A - Working multiple access code plus 0000 = no entry 30 codes - last two dont work.fcf
- (21.51 KiB) Downloaded 465 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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.Anyone know where I'm going wrong?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
Sorry if it is Ben, as its the way I would tackle this issue.
Martin
- Attachments
-
- Door Lock 16F877A - Working multiple access code plus 0000 V2.fcf
- (20.92 KiB) Downloaded 548 times
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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
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
Martin
-
- Posts: 2
- Joined: Fri Dec 06, 2013 3:19 pm
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
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!
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!
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Basic Keypad - LCD Four Digit Door Lock.
Hi obertelli7,
Welcome ot the forums.
If you would like to post your flowchart, I can take a look at it for you.
Martin
Welcome ot the forums.
If you would like to post your flowchart, I can take a look at it for you.
Martin
Martin
-
- Posts: 2
- Joined: Fri Dec 06, 2013 3:19 pm
- Contact: