problem programming a keypad

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

problem programming a keypad

Postby Francisco Cabrera » Mon May 23, 2016 9:23 pm

Hello, good evening, I have a problem programming a keypad, In the photo I have touched the number 12 but the number appears 01 .... Can I solve this?
Attachments
capturada.jpg
capturada.jpg (185.21 KiB) Viewed 6184 times

kersing
Valued Contributor
Valued Contributor
Posts: 1877
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 533 times
Been thanked: 1043 times
Contact:

Re: problem programming a keypad

Postby kersing » Mon May 23, 2016 10:14 pm

Please read this post. One of the items is a request to post the flowchart with issues as it helps us understand what you are doing. A screen capture of a flowchart is NOT a flowchart as it lacks a lot of information.
These users thanked the author kersing for the post (total 2):
dazz (Thu May 26, 2016 3:55 pm) • Francisco Cabrera (Fri May 27, 2016 3:04 pm)
Rating: 10.53%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: problem programming a keypad

Postby Francisco Cabrera » Tue May 24, 2016 8:21 am

Ok. your you have reason, excuse, he will remember it for another occasion ,He sent the fcfx ... thank you
Attachments
Flowcode keypad ok.fcfx
(6.6 KiB) Downloaded 142 times

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: problem programming a keypad

Postby Francisco Cabrera » Wed May 25, 2016 8:54 pm

I have tried modifying all the parameters of configuration and I do not obtain it, please someone can help me? Thank you......... :(

User avatar
LeighM
Matrix Staff
Posts: 1929
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 464 times
Been thanked: 656 times
Contact:

Re: problem programming a keypad

Postby LeighM » Thu May 26, 2016 9:01 am

Hi,
There is a difference in the meaning of the return value for these macros.
The WaitPressed() returns the index (or scan code) for the key, the same as GetIndex()
The GetNumber() converts the scan code into a key number and returns that instead.
Leigh
These users thanked the author LeighM for the post:
Francisco Cabrera (Thu May 26, 2016 2:05 pm)
Rating: 5.26%
 

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: problem programming a keypad

Postby Francisco Cabrera » Thu May 26, 2016 2:17 pm

After many hours, I have advanced enough............ Only I need to learn how I can compare the number written in the LCD with a number written in a variable? Please can you help my? please :?
Attachments
Flowcode keypad ...fcfx
(8.09 KiB) Downloaded 147 times

User avatar
LeighM
Matrix Staff
Posts: 1929
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 464 times
Been thanked: 656 times
Contact:

Re: problem programming a keypad

Postby LeighM » Thu May 26, 2016 2:58 pm

Hi
If you are wanting to compare with more than one key press, example for a pin number lock,
you will need to either put each key pressed into a string array, then compare the array with the lock code, e.g. "1234"
Or, you could calculate the lock number, like so...

Code: Select all

code = 0
loop
    key = getAscii()
    if key <> 255
        code = (code * 10) + key - '0'
        if code = 1234
              code OK
These users thanked the author LeighM for the post (total 2):
dazz (Thu May 26, 2016 3:54 pm) • Francisco Cabrera (Thu May 26, 2016 4:53 pm)
Rating: 10.53%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8472
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3482 times
Contact:

Re: problem programming a keypad

Postby medelec35 » Thu May 26, 2016 3:06 pm

I created a flowcode V5 simple door lock.
That could also give you an idea on how to compare entered numbers with a number stored within a variable.
You can load it into flowcode V6 by using Open, then changing Flowcode project files (*.fcfx) drop down to Flowcode for pic files (*.fcf)

Martin
These users thanked the author medelec35 for the post (total 3):
LeighM (Thu May 26, 2016 3:52 pm) • dazz (Thu May 26, 2016 3:54 pm) • Francisco Cabrera (Thu May 26, 2016 4:53 pm)
Rating: 15.79%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8472
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3482 times
Contact:

Re: problem programming a keypad

Postby medelec35 » Thu May 26, 2016 10:06 pm

Hi,
I have simplified the flowchart for you.
You can use * to clear.
When number matches the stored variable, LED changes from red to green.

Martin
Attachments
Flowcode keypad 2.fcfx
(11.08 KiB) Downloaded 164 times
These users thanked the author medelec35 for the post:
Francisco Cabrera (Fri May 27, 2016 3:04 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: problem programming a keypad

Postby Francisco Cabrera » Fri May 27, 2016 2:31 pm

Now I understand it much better, many graces, only I have one doubts, them in the photo... Please, forgive my ignorance, Everything else if I understand it well
Attachments
capturada.jpg
capturada.jpg (145.22 KiB) Viewed 6051 times
Last edited by Francisco Cabrera on Fri May 27, 2016 3:28 pm, edited 1 time in total.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8472
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3482 times
Contact:

Re: problem programming a keypad

Postby medelec35 » Fri May 27, 2016 3:20 pm

Hi,
Francisco Cabrera wrote:only I have one doubts, them in the photo.

What photo?

Martin
These users thanked the author medelec35 for the post:
Francisco Cabrera (Fri May 27, 2016 4:25 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: problem programming a keypad

Postby Francisco Cabrera » Fri May 27, 2016 3:40 pm

Excuse I was modifying the photo, because before I tape-worm 2 doubt, and now alone I have only one....
Attachments
capturada.jpg
capturada.jpg (145.22 KiB) Viewed 6048 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8472
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2433 times
Been thanked: 3482 times
Contact:

Re: problem programming a keypad

Postby medelec35 » Fri May 27, 2016 4:01 pm

for the first one
RESULTADO = RESULTADO * 10 + numero_teclado
for example if RESULTADO starts off = 0
If you press 1 on the keypad
0 x 10 +1 = 1
then 1 is stored in RESULTADO
If 2 is now pressed then:
1 x 10 + 2 = 12
Now if 3 is pressed
12 x 10 + 3 = 123

So the number stored before pressing a number on the keypad is multiplied by 10 then the key pad number is added to the result.

The lower one is just a decision branch.
In English:

Is the number stored in a variable called abre = result entered in the keypad?
If Yes then set port C bit 2 high and bit 1 low
If No then port C bit 1 high and bit 2 low

Martin
These users thanked the author medelec35 for the post (total 2):
Francisco Cabrera (Fri May 27, 2016 4:25 pm) • Benj (Thu Jun 02, 2016 4:14 pm)
Rating: 10.53%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Francisco Cabrera
Posts: 47
Joined: Sat Mar 19, 2016 4:56 pm
Location: Canary Island
Has thanked: 23 times
Been thanked: 7 times
Contact:

Re: problem programming a keypad

Postby Francisco Cabrera » Fri May 27, 2016 4:24 pm

Medelec, thank you very much, you have gained my friendship forever, because I see that you are a good person for having bothered to help me so much ... I expect some day to be able to return the favor to you .... thank you :D :D :D
These users thanked the author Francisco Cabrera for the post (total 2):
medelec35 (Fri May 27, 2016 5:32 pm) • dazz (Fri May 27, 2016 9:09 pm)
Rating: 10.53%