Mapping a switch pressed in a keypad into the character it represents

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am writing a code that detects a key press in a 4 X 4 keypad, it detects the row and column of the pressed key successfully and gives them to me.

The question now, how can I turn the row and column numbers of a pressed key into the ACII code of the number or letter on the key.

I use the keypad in the image below 

 

 

If for example, I press the '6' key, the function gives 2 for the row and 3 for the column. If I press the 'C' key, the function gives 3 for the row and 4 for the column and so on.

How can I convert the two numbers 2(row) and 3(column) to decimal 54 that is the ACII code for the character '6' and so on.

There is the table that I have created to convert 

 

 

Mathematically speaking, I need to derive the 'ASCII value' column as a function of the 'Row' and 'Column' columns.

Or if anybody has another method to convert , you are welcome to say it.

 

This topic has a solution.
Last Edited: Tue. Aug 6, 2019 - 06:49 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

keypad[4,4] = {'1','2','3','A'......};     //does that help?

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which language is it that supports that [4,4] syntax?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Which language is it that supports that [4,4] syntax?

I think C# supports that.

Last Edited: Tue. Aug 6, 2019 - 05:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Which language is it that supports that [4,4] syntax?

Must be BASIC....   ok, keypad[4][4] = {......  

it's been awhile since I've done a multidimensional array....

Anyway, I think the OP now has an idea how to convert their row/col into an ASCII char.

 

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Tue. Aug 6, 2019 - 05:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can use a 4 bit, 16 value, look up table (list).

 

note your rows &cols  should be from 0x000 (0) to 0x0011 (3)  for simplicity

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. Aug 6, 2019 - 06:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

keypad[4,4] = {'1','2','3','A'......};     //does that help?

 

Jim

 

 

Thanks, I discovered it before seeing your post. But that does not mean that I want to thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But that does not mean that I want to thank you.

Thanks laugh 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!