Keypad

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

Moderators: Benj, Mods

Post Reply
User avatar
goldwingers
Posts: 118
Joined: Wed Sep 06, 2006 1:22 pm
Location: London
Been thanked: 1 time
Contact:

Keypad

Post by goldwingers »

Hi guys,
Just to throw a query or two over to you,

1 - There is no help file for the keypad component, it would help us amateurs out

2 - when using the kepad component, how do you retrun the zero key, the system dont seem to like key number "12" or asc "0", got me baffled, I just want to load a 4 digit code and each keystroke into a variable thats all but i need the zero key ie 2006

Aslo could you put something up to load EEprom locations with a digit

Many thanks for a superb product,

regards

Ian

User avatar
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:

Post by Benj »

Hello Goldwingers

1. A simple flowchart to read in the number from the keypad. This is a decimal value and not the ascii value of the decimal.

Below is an example in Psudo code which should convert straight to flowcode.

Component Macro Init LCD Display
While 1
{
Component Macro Clear LCD
Component Macro Get Keypad Number -> Variable
Variable -> Component Macro LCD Print Number
}

This should render the number 0 when pressed. To then convert the number to ascii simply add 48 in decimal to the variable.

As for storing data in the EEPROM. Flowcode can take care of this for you but if you are wanting to achieve this in code then you have to follow a strict set of instructions. Refer to the device datasheet on how to do this.

User avatar
Steve
Matrix Staff
Posts: 3421
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

The keypad component routines will both return 255 if no key has been pressed.

As for the EEPROM, the Flowcode component may suit your needs. If you want to have initial EEPROM data that does not get reset each time the PIC is reset, you can use the "#pragma DATA" line in the supplementary code section - this is detailed in another forum post.

User avatar
goldwingers
Posts: 118
Joined: Wed Sep 06, 2006 1:22 pm
Location: London
Been thanked: 1 time
Contact:

Hmm

Post by goldwingers »

Thanks for the two replies guys and i will answer the first one, I understand the code you put down and have already gone that far but maybe i didnt explain my problem thoroughly... I need 4 variables ie KP1, KP2,KP3, KP4... I need to load each of these variables with one keystorke on the keypad, so:-

KP1 = 2
KP2 = 0
KP3 = 0
KP4 = 6

Then add the lot together in another variable say KPsum to make 2006. This is then used in choosing a model / make year via decision boxes. the range i need is 1988 - 2004......

The second reply I saw the post in the forum just after ii had sent my initial question, but what component do you use to load the eeprom

Hope this explains it better

Ian

User avatar
Steve
Matrix Staff
Posts: 3421
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Hmm

Post by Steve »

goldwingers wrote: The second reply I saw the post in the forum just after ii had sent my initial question, but what component do you use to load the eeprom
Use the "WriteEEPROM" macro of the EEPROM component if you want to add data to the EEPROM within your program.

If you want to pre-load the EEPROM with data that is not reset when the PIC is restarted, use the "#pragma DATA..." technique.

User avatar
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:

Post by Benj »

Hello Goldwingers

To add these 4 variables together you need to create a string of at least 4 characters. Then you can use the string manipulation functions to chop and change the variable as needed.

To put data into the EEPROM that does not get reset when the PICmicro is reset or loses power, put the following into the "definitions" section of the "supplementary code" section (assuming you're using v3):

Code: Select all

//Put some data into eeprom 
#pragma DATA 0x2100, 12, 34, 0x56, 0x78, "ABCD" 
This will put the values 12, 34, 56(hex) and 78(hex) into locations 0-3 of EEPROM, and the ASCII codes for A-D into locations 4-7.
There is also the flowcode EEPROM component with which you can read and write to the PICmicros EEPROM during a program.

Post Reply