3x4 alpha numeric keypad - Page 2


Today 00:01
Forum: LCD module
Starter: charliecoultas
Views: 0
Replies: 36
Go to last post By: KrysG
Yesterday 21:34
Forum: The Lounge
Starter: pic-ignorant
Views: 0
Replies: 1
Yesterday 21:12
Forum: CAN Module
Starter: RGV250
Views: 0
Replies: 6
Yesterday 15:38
Forum: Proton Plus Compiler v3
Starter: Frizie
Views: 0
Replies: 2
Yesterday 10:11
Forum: The Lounge
Starter: Tim
Views: 0
Replies: 0
+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: 3x4 alpha numeric keypad16 days old

  1. #11
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    481
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.34 GB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    Quote Originally Posted by amod View Post
    I can't get, how to define rows and columns for inkey command.I saw in PDS SAMPLES but example is not Full
    In general you don't have to, the Declare Keypad_Port command (manual page 143) will configure the port as per the diagram shown, so RB0:3 are your Rows (outputs) and RB4:7 are your Columns (inputs). It has to do it this was otherwise other commands like Inkey would not work correctly if the user defined which I/O pins where the Rows & Columns as it would have no way of knowing which you are using. Specifically regarding the Inkey sample code that is set up in the Proton_4 include file.
    You can of course write your own keypad code, then you could use whichever I/O pins you want. It is quite simple, every time you want to check the keypad you set the I/O pin for a row high, read the column input pins, which (if any) input is high identifies which button in that row was pressed, then you simply repeat until either all the rows have been checked or a key press has been detected.

    For the Inkey sample code I believe (not checked the ASM to confirm) that the InKey command itself results in assembler code that does essentially the same thing as the Keypad sample code (look at it if you want to pick your own I/O Row & Column pins) in that it scans the entire keyboard and returns whichever (or first found of multiple) button was pressed.

    In the Keypad sample code GetKeyP performs a loop that will constantly scan the entire keyboard until a key press is detected (Row <> $0F), when a key press is detected it then jumps to GotKey which multiplies the column number by 4 and adds the row to create a number from 0 - 16 (0-12 for 3x4) thereby identifying which key was pressed.

    In the Inkey sample takes that further but converting the pressed key number that the Keypad sample produces and assigning it an alphanumerical character, it first prints the number of the pressed key (255 = no press), then prints the corresponding key legend. Basically, the alphanumerical constants in the LookUp command are an array of characters and the number of the key pressed retrieves the character in the corresponding element number of the array.

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #12
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    Got inkey worked.
    How can I write my name on LCD using keypad and store it.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #13
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    56
    Thumbs Up
    Received: 14
    Given: 0
    Total Downloaded
    144.28 MB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    It's up to you to determine which of the 16 keys to map to the particular LETTER you are trying to generate. Maybe try something similar to the way telephone keypads are used to send TEXT.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #14
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    I can't write names using keypad.Pls give an example

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #15
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    56
    Thumbs Up
    Received: 14
    Given: 0
    Total Downloaded
    144.28 MB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    I have NO examples, Just think about how you use the keypad on your phone to do texting... Most keys use 4 different toggles to decode the alphabet.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #16
    Member craig's Avatar
    Join Date
    Dec 2010
    Posts
    196
    Thumbs Up
    Received: 12
    Given: 0
    Total Downloaded
    1.11 GB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    Amod

    After you have the Keypad Working then Make a note of what is being displayed on the LCD when you push each key on the Keypad.
    You can start by using a Select ..Case Command. I have Inserted just a small piece of code to give you the Idea - LOOK At the ASCII Table
    At the Top of the Proton IDE and you will See that Each Key Has a Char,Dec,Hex,Bin Value Attached to Each Character(KEY) so you need to make a table as below to catch them and then you can put then into a VARIABLE and then if you like into an ARRAY Etc. then print the ARRAY in Decimal (Dec) or Hexadecimal (Hex) Etc. "The Character A = 065 in Decimal and 041 in Hexadecimal and 01000001 in Binary"
    I hope that this helps you to understand!

    Regards

    Craig

    '-------------------------------------------------------------------------------------------------------------------

    Time_Convertor:

    Select Hex_Dec_Convertor 'Dec = Hex "CASE = The Hexadecimal Value"

    Case 0 '0 = 0 "CONVERTOR_VALUE = The Decimal Value"
    Convertor_Value = 0
    Case 1 '1 = 1
    Convertor_Value = 1
    Case 2 '2 = 2
    Convertor_Value = 2
    Case 3 '3 = 3
    Convertor_Value = 3
    Case 4 '4 = 4
    Convertor_Value = 4
    Case 5 '5 = 5
    Convertor_Value = 5
    Case 6 '6 = 6
    Convertor_Value = 6
    Case 7 '7 = 7
    Convertor_Value = 7
    Case 8 '8 = 8
    Convertor_Value = 8
    Case 9 '9 = 9
    Convertor_Value = 9
    Case 10 '16 = 10
    Convertor_Value = 16
    Case 11 '17 = 11
    Convertor_Value = 17
    Case 12 '18 = 12
    EndSelect

    '--------------------------------------------------------

    The key being pressed will be written to the Variable Called Convertor_Value

    Repeat

    If UP = 0 Then DelayMS 250 : Inc ACnt ' Debounce Switch 250Ms
    If DOWN = 0 Then DelayMS 200 : Dec ACnt
    If DOWN = 0 Then DelayMS 10 : If ACnt = 0 Or ACnt = 255 Then ACnt = 23

    A = ACnt
    AHour1 = A
    DelayMS 5
    If ACnt = 255 Then AHour1 = 0 ' Stops Down Key Printing 255
    Print At 2,4,Hex AHour1," " ' "DEBUGGING" PRINT HOURS 10
    Print At 1,12,Dec AHour1," " ' PRINT HOURS 10

    A = ACnt
    AHour1 = A
    DelayMS 5
    If ACnt = 255 Then AHour1 = 0 ' Stops Down Key Printing 255
    Print At 2,4,Hex AHour1," " ' "DEBUGGING" PRINT HOURS 10
    Print At 1,12,Dec AHour1," " ' PRINT HOURS 10

    If LEFTKey = 0 Then ' Move One step to the "FORWARD"
    DelayMS 25 ' Debounce Switch
    Hex_Dec_Convertor = AHour1
    GoSub Time_Convertor
    AHour1 = Convertor_Value ' Convertor_Value1
    AHourR1 = AHour1
    ' Print At 2,2,"H",Hex AHour1," " ' Unclear For Testing Purposes
    ' Print At 2,10,"D",Dec AHour1," " ' Unclear For Testing Purposes
    ' DelayMS 1500 ' Unclear For Testing Purposes
    GoTo Loop2S
    EndIf

    If RIGHTKey = 0 Then ' Move One step to the "BACKWARD"
    DelayMS 25 ' Debounce Switch
    Hex_Dec_Convertor = AHour1
    GoSub Time_Convertor
    AHour1 = Convertor_Value ' Convertor_Value1
    AHourR1 = AHour1
    ' Print At 2,2,"H",Hex AHour1," " ' Unclear For Testing Purposes
    ' Print At 2,10,"D",Dec AHour1," " ' Unclear For Testing Purposes
    ' DelayMS 1500 ' Unclear For Testing Purposes
    GoTo MENU_SETUP
    EndIf

    If ENTER = 0 Then DelayMS 25 : GoTo Paint

    Until ACnt > 23 ' Rolls Over at 23H00 Hrs
    If ACnt > 23 Then ACnt = 0 ' Clear the ACnt Variable

    '------------------------------------------------------------------------------------------------------------

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #17
    Fanatical Contributor fanie's Avatar
    Join Date
    Oct 2005
    Posts
    7,964
    Thumbs Up
    Received: 53
    Given: 13
    Total Downloaded
    280.03 MB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    If you understand how the keypad works, then the software is going to be very easy.
    You need to to sit with a multimeter and the keypad diagram ONLY ONCE, and you will never have trouble with it again.
    Fanie

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #18
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,269
    Thumbs Up
    Received: 38
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    Hi Fanie, how ya doin' we miss you!

    Getting INKEY to work is easy but for what Amod is looking for, changing character sets and getting the timing right gave me more of a problem.

    I still have to check out Alberto's InkeyX on the WIKI to see if I can improve my attempts. I should be able to do better using a Timer module.

    My first attempt timed the key down and incremented the character set every 250mS. It worked but was not a practical solution.

    The second counts delays when the key is released to determine whether to change character set or move to the next print position. It is far from perfect and needs some more work but here it is>

    Code:
    Declare Keypad_Port PORTC        ' NOTE PortB is the default
    Dim Key As Byte
    Dim Character_Set As Byte
    Dim Delay_Counter As Byte
    Dim Temp1 As Byte
    Dim T1 As Byte
    Dim T2 As Byte
    Dim T3 As Byte
    Dim X As Byte                    ' Horizontal or position
    Dim Y As Byte                    ' Vertical or line
    Dim ASCII As Byte              ' Character
    Dim LED2 As PORTB.1
    
        DelayMS 100
    Start:
        Print Cls                       ' test display
        Print "Ready "
        High LED2                        ' Green LED next to buttons
        DelayMS 500
        Low LED2
        Print Cls
        Character_Set = 1
        X = 1                        ' first print across
        Y = 1                        ' print on line 1   
        T1 = 15                      ' Delayms * 
        T2 = 30                      ' delayms * 
        T3 = 60
        Key = 255                    ' set key value to a non-printable character
        Print $FE,$0E                ' underline cursor on
    
    Get_Key:
    ' if the next three lines are inside the While-Wend it creates Key press errors
        While InKey <> 16             ' wait for key up before starting
            DelayMS 50
        Wend
    While
    
        DelayMS 25
        High LED2                    ' indicate we are ready for a keypress    
    
        While InKey = 16
    '        Temp1 = InKey            ' add timeout and return to main program here
            Delay_Counter = 0
        Wend
        
        DelayMS 50
        High LED2
        Key = InKey
    '    If Key <> 16 Then GoSub Display    
        DelayMS 50
        Low LED2                      ' busy so turn LED2 off
        
        While InKey <> 16 : Wend
        
        High LED2    
        DelayMS 50    
    
        While InKey = 16 And Delay_Counter < T3     ' key up so start counting
            DelayMS 50
            Inc Delay_Counter
        Wend
    
        Low LED2    
        If Delay_Counter < T1 Then
            Inc Character_Set                       ' Change character set
            If Character_Set = 6 Then Character_Set = 1
        EndIf
        
        If Delay_Counter > T2 Then
            Inc X
            Character_Set = 1
        EndIf
        If X > 20 Then
            X = 1                        ' move to start of line
            Inc Y                        ' next line
            If Y = 5 Then Y = 1
        EndIf    
        Delay_Counter = 0
    
    Wend
    
    ' #################### convert Key to ASCII and print to LCD ##################
    ' because we are using a 4 row by 3 column keypad Then every fourth character
    ' is set to DEC 0 = NUL
    ' on my keypad Key 3 is "#". ASCII DEC 8 = Backspace, DEC 32 = Space
    ' Key * clears the screen.
    ' Press key 0 once to insert a space, twice to print 0
    ' Press # to delete last character and move curcsor back
    Display:                       
        Select Character_Set       ' 
            Case 1                 
                ASCII = LookUp Key,["*",32,8,0,55,56,57,0,52,53,54,0,49,50,51,0,255]
            Case 2
                ASCII = LookUp Key,["*",48,0,0,80,84,87,0,71,74,77,0,49,65,68,0,255]                
            Case 3
                ASCII = LookUp Key,["*",0,0,0,81,85,88,0,72,75,78,0,49,66,69,0,255]
            Case 4
                ASCII = LookUp Key,["*",0,0,0,82,86,89,0,73,76,79,0,49,67,70,0,255]
            Case 5
                ASCII = LookUp Key,["*",0,0,0,83,86,90,0,73,76,79,0,49,67,70,0,255]                
        End Select
        
        If ASCII > 31 And ASCII < 95 Then Print At Y,X, ASCII  ' 32 = space, 48 = Number 0
        
        If ASCII = 8 Then
            Print $FE,$10,$20                   ' Print "\b" does not work
            X = X - 2                           ' move cursor back
            Print At Y,X-1                      ' ?
        EndIf
        
        If ASCII = "*" Then
            Cls
            X = 1
        EndIf
        High LED2
        Return                                 ' enable to defeat debug display
    
    Display2:
    ' Last Character set,  Delay Counter, Print at Y,X, Last key pressed  
        Print At 3,1,"Set  Delay X   Last"
        Print At 4,1, Dec2 Character_Set
        Print At 4,6, Dec3 Delay_Counter    
        Print At 4,12,Dec2 X                   ' Print at
        Print At 4,16,Dec2 Key               ' last key press, 16 = no key
        Print At Y,X+1        
    '    If Delay_Counter >= T3 Then Delay_Counter = 0
    '    Print at 1,1,$FE,$0E                    ' underline cursor on
    Return 
    End
    I am using a four line by twenty display on PortB for testing and there is no ENTER key yet.
    Last edited by See_Mos; 11th September 2019 at 16:12.
    My RAM is failing

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #19
    Junior Member Ioannis's Avatar
    Join Date
    Sep 2012
    Posts
    33
    Thumbs Up
    Received: 13
    Given: 1
    Total Downloaded
    1.20 GB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    I guess what Amod is looking for is something like this?

    Code:
    if key_is_pressed then
        character=character+1
        if character>last_character then character=first_character
    endif
    Ioannis

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #20
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,312
    Thumbs Up
    Received: 79
    Given: 39
    Total Downloaded
    3.36 GB

    0 Not allowed!

    Default Re: 3x4 alpha numeric keypad

    Fanie

    It's good to hear from you. How is the book coming along?

    Charlie

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Numeric conversion trouble
    By NEX in forum Proton Plus Compiler v3
    Replies: 19
    Last Post: 11th January 2018, 19:44
  2. Print using a SPI I/O expander to a Alpha numeric display
    By yvesmazzon in forum Projects discussion
    Replies: 1
    Last Post: 22nd September 2017, 11:42
  3. Replies: 0
    Last Post: 23rd August 2011, 06:49
  4. keypad 3X4 (newbie)
    By stopper in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 11th December 2009, 23:13
  5. Text and numeric data to strings.
    By RGV250 in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 22nd October 2007, 00:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts