Keypad scan for HCS12 microprocessor

I need to read the button pressed on a 4x4 keypad, connected to Port E on the MCU.  This is for user to enter frequency, so several "presses" need to be stored in an array.  My confusion is how I actually get this number.  Apparently if PortE is pressed, it is a logic 0.  I've done some reading an understand the idea of making a table of rows and columns associated with keys, just don't know how to load the ascii code pressed into a variable.  Don't think I can just do  newnumber=PTE;

Any advice would be great.  
rem2722Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony2000Commented:
I am assuming that PortE will contain a different pattern of values, each will represent which key on the keypad was pressed. With 4x4 keypad you can have 16 patterns which can represent the 16 values that PortE can have.

So, if you create a table of values which can hold the ASCII representation of the keypad. You can do something like this:

char key_2_ascii[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};


if(PortE < sizeof(key_2_ascii)
{
    x = PortE;
    ascii char pressed = key_2_ascii[ x ];
}

Are you starting to understand?

Other things to consider are polling PortE and debouncing a keypress.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.