Line 50: Line 50:
  
  
=Usage guide==
+
==Usage guide==
 +
<syntaxhighlight>
 +
#include"keypad.h"
 +
#include"lcd.h"
 +
#include "delay.h" 
 +
 
 +
 
 +
/* Program to demonstrate the hex-Keypad interface*/
 +
int  main()
 +
{
 +
  uint8_t key;
 +
  LCD_Init(8,2,16);            /*Initialize the 2x16 LCD in 8-bit mode */
 +
  KEYPAD_Init();              /*Configure the ROWs and COLUMNs for keypad scanning*/
 +
 
 +
while(1)
 +
{
 +
key = KEYPAD_GetKey(); /*Get the Ascii value of the key Pressed */
 +
LCD_DisplayChar(key);  /*Display the key pressed */
 +
}
 +
 
 +
return 0;
 +
}
 +
 
 +
</syntaxhighlight>

Revision as of 17:44, 27 December 2014


KEYPAD

KEYPAD_Init

{{#Widget:LibTable}}
Defination void KEYPAD_Init()
Input Arguments none
Return Value none
Description This function configures the rows and columns for keypad scan.
  • ROW lines are configured as Output.
  • Column Lines are configured as Input.
Usage



KEYPAD_GetKey

{{#Widget:LibTable}}
Defination unsigned char KEYPAD_GetKey()
Input Arguments none
Return Value uint8_t--> ASCII value of the Key Pressed
Description This function waits till a key is pressed and returns its ASCII Value.

It follows the following sequences to decode the key pressed:

  • Wait till the previous key is released..
  • Wait for the new key press.
  • Scan all the rows one at a time for the pressed key.
  • Decodes the key pressed depending on ROW-COL combination and returns its

ASCII value.

Usage



Usage guide

  1. #include"keypad.h"
  2. #include"lcd.h"
  3. #include "delay.h"
  4.  
  5.  
  6. /* Program to demonstrate the hex-Keypad interface*/
  7. int main()
  8. {
  9. uint8_t key;
  10. LCD_Init(8,2,16); /*Initialize the 2x16 LCD in 8-bit mode */
  11. KEYPAD_Init(); /*Configure the ROWs and COLUMNs for keypad scanning*/
  12.  
  13. while(1)
  14. {
  15. key = KEYPAD_GetKey(); /*Get the Ascii value of the key Pressed */
  16. LCD_DisplayChar(key); /*Display the key pressed */
  17. }
  18.  
  19. return 0;
  20. }