![]() |
||||||||||||||||||||||
![]() |
You can program the PIC in circuit through the ICSP connector. LCD Keypad Port DirectionsWhen using the LCD you need to set all LCD pins as outputs and for the keypad you need to set rows as inputs and columns as outputs. To make it work all row inputs must be pulled up to 5V (either by internal port pullups or by external 10k resistors). Note : During keypad access the LCD strobe signal (E) must be kept at zero so that the LCD is not activated. How the lcd keypad worksReading the keypadThe software generates a walking 0 through the columns. Whenever you press a key the keypad shorts column to the row so the zero from the column output appears at the row input pulling the voltage to ground. When there are no keys pressed the pullup resistors pull the row inputs to 5V. The routine exits with the first key detected. This key is derived from the returned row value and the current mask value and you can decode it using the definitions found in lcd_keypad.h e.g. KEY_2 has the value 226 which is the value returned by read_KEYPAD when key 2 is hit. Column shortsPressing two keys in different columns and rows shorts together two columns that are at different voltages (one at 0V and one at 5V). The column drivers are isolated by the three 10k resistors to prevent damage. They also allow the LCD to operate correctly even when keys are pressed. Kepad wiringThe following diagram shows the keypad wiring which is a little awkward - probably to allow a simple pcb routing path.
Software operationThe software consists of three files: 16F887A_lcd_keypad.c The most important routines are KEYPAD_access() and LCD_access() - which set the port up to let it control the keypad and lcd respectively. The interesting point about the code is that the standard LCD routines (provided by compiler manufacturer) are used after lcd_access() is executed. Pressing a key displays the result on the lower right of the 2 row LCD. Note that key debouncing has not been done as it does not affect the demonstration but you must use it for a 'real' application. Jump from LCD keypad Page to Best-microcontroller-projects home page Please enter the Password.
|
|||||||||||||||||||||

































