.

QuickBuilder
for Microchip PICs

Home - About- Consulting* - Articles - FAQs - Contact
Tour - Application Example - Sub circuits - Projects - Download
Projects: Generic serial 64-way matrix keypad

This QuickBuilder project can be downloaded here.

 

Generic serial 64-way matrix keypad


Introduction
This project demonstrates a serial keypad using the 'Keypad 16x4 Decoded' and 'RS232 Transceiver' sub-circuits

The target device is a PIC16F84 running at 4MHz


Operation
The keypad is scanned at regular intervals by calls made from the timer tick routine RTCC_ISR. When a key is pressed its scan code is transmitted out of the RS232 port.


Application code
Below is the application code for this project. To use it, select and copy (ctr-insert) the code below and past it into a text editor and save as a 'C' file in your working directory. You may also need to change the build output path using 'Project | Options'

///////////////////////////////////////////////////////////////////////
////                           ASERKP1.C                           ////
////  Demonstration of the 'Keypad 16x4 Decoded' sub-circuit.      ////
////  This generic debounce keypad driver is for keypads in        ////
////  arranged in a 'n'x4 matrix. Two or more keypads can be       ////
////  used at the same time providing the column count 'n' does    ////
////  not exceed 16.                                               ////
////                                                               ////
////  This program is an example of how your application code is   ////
////  is organised. Note the #include "serkp1.c", this include     ////
////  file was generated by QuickBuilder and contains all          ////
////  driver code.                                                 ////
////                                                               ////
////  This demo is intended for  a PIC16F84                        ////
////  Compile using CCS 'C'  visit www.quickbuilder.co.uk/qb/ccs   ////
///////////////////////////////////////////////////////////////////////
#include <16f84.H>

#fuses   XT,NOPROTECT,NOWDT

#case

#define PORTA 5 
#define PORTB 6
#define TRISA 0x85 
#define TRISB 0x86


#include "serkp1.c"


#int_rtcc 
void RTCC_ISR()
{
    KEYPAD_1DO();    // scan keypad
}


main() {
    BYTE newkey;
    

    // initialise sub-circuits and rtcc interrupts
    //--------------------------------------------
    INIT_SUB_CIRCUITS();    
    setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
    enable_interrupts(INT_TIMER0);
    enable_interrupts(GLOBAL);

        // main loop
        //----------
        while(1) {
        newkey = KEYPAD_1NEWKEY();
        if ( newkey ) {
            disable_interrupts(GLOBAL);
            RS232_1OUT(newkey);
            enable_interrupts(GLOBAL);
        }
    }
}
Copyright 2002-2009 Summit Electronics Ltd
www.quickbuilder.co.uk