Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

:confused:Help in numeric keypad concept.:confused:

Status
Not open for further replies.

xxxnonoxxx

New Member
Help in numeric keypad concept.

Hi all, need some help on the concept of numeric keypad for peer teaching.
Hope you all can provide me with some basic informations of keypad concepts or the website address. Can also include schematic diagrams and source codes. Thank alots :) :confused:
 
Last edited:
There are thousands of examples out there, but here's another
Swordfish has its own keypad library, but its default use is for 4 * 4 keypads like this;
**broken link removed**
The problem is that a lot of people use the 4 * 3 keypads without the "ABCD" as shown above. This example shows you how to use the keypad library, and convert the keypad value returned to that for a 4 * 3 keypad.


**broken link removed**
If your using PORTB for the keypad, then enable PORTB internal pullups, and you don't require the three 10K external resistors. The four 470ohm resistors are to ensure there is no short circuiting occurring if multiple keys are pressed, as the four rows are outputs, and if one is set high and more than one key is pressed, well it leads to bad things without the resistors...

Code:
Device = 18F452
Clock = 20

#option LCD_DATA = PORTC.4
#option LCD_RS = PORTC.2
#option LCD_EN = PORTC.3   
#option KEYPAD_PORT = PORTD     

Include "keypad.bas" 
Include "convert.bas"   
Include "LCD.bas"

Function Convert_Key() As Byte     // Function to convert the key pressed to the 
                                           //  actual number (* = 10 # = 11)
    Select Keypad.Value
        Case 5
            Result = 4
        Case 6
            Result = 5
        Case 7
            Result = 6
        Case 9
            Result = 7
        Case 10
            Result = 8
        Case 11
            Result = 9
        Case 13
            Result = 10
        Case 14
            Result = 0
        Case 15
            Result = 11
        Else
            Result = Keypad.Value
    EndSelect

End Function

Sub Debounce()

    DelayMS(10)                            // Simple debounce routine
    
    While Keypad.Value <> 0                // Wait for key to be depressed
    Wend                                   //
     
End Sub

 

// Start Of Program...		 
DelayMS(150)                               // Allow LCD to warmup
Cls                                        //  and clear the screen  
	                                       
WriteAt(1,1,"Press any key...")            // Send some text to the LCD
	
Main:                                      // Main program start

    While Keypad.Value = 0                 // Loop until a key is pressed
    Wend
    
    WriteAt(2,1, DecToStr(Convert_Key,2))  // Convert the Key to a string and display it
    
    Debounce                               // Call the debounce routine
    
    GoTo Main                              // Loop forever
 
gramo, thank you very much for providing me with the informations. I think i misunderstood that the numeric keypad itself include the "ABCD". So the keypad I researching on is called the 4 * 4 keypad.

Can you tell me more about Swordfish? How do I find it cause I hope to get some example from there.
Can you also tell me how is the keypad related to the 16-Key Encoder and the Touch Sensor with some diagrams? Sorry for the trouble.
 
Thank Nigel for the link. The tut 9 was useful as it tell me how the Hex keypad work, but some of the term used was confusing. Can you show me some simple source code, so i can understand it clearer?
 
xxxnonoxxx said:
Thank Nigel for the link. The tut 9 was useful as it tell me how the Hex keypad work, but some of the term used was confusing. Can you show me some simple source code, so i can understand it clearer?

That is the simple source code! :eek:

Essentially you treat it a single row of four buttons, which you can easily check if (and which) one is pressed, you then select the next row of four and do the same, and repeat continually - it's called multi-plexing.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top