Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

4x4 matrix keypad with 16f690

Status
Not open for further replies.

neillsun

Junior Member level 2
Joined
Jul 12, 2007
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
London, UK
Activity points
1,442
I am pulling my hair out with this one...

I have a 4x4 matrix ketpad connected to pins RC0 thru RC7 (RC0-RC3 are columns and RC4 thru RC7 are rows).

I have connected RC4-7 to ground through 10k resistors, and I am using the following code (PICCLite in MPLAB IDE) which I got from http://www.rs232pro.com/keypad_hardware.htm, I also copied the basic circuit, but I am relying on the internat OSC, so I haven't added the XTAL:

Code:
#include <pic.h>
#include "delay.h"

#define INPUT 1
#define OUTPUT 0

void main()
{

    const unsigned char keypad[]= {0x11,0x21,0x41,0x81,0x12,0x22,0x42,0x82,0x14,0x24,0x44,0x84,0x18,0x28,0x48,0x88};
    const unsigned char character[] = {'1','2','3','A','4','5','6','B','7','8','9','C','*','0','#','D'};
    unsigned char i,ii;

    TRISA3=OUTPUT;
    TRISC=0xFF;
    PORTC=0xF0;
  
    RA3=1;

    while(1)
    {
        PORTC=0x0F; /* init/re-init port */
        while(PORTC==0x0F); /* wait for key press */
        DelayUs(10);
        if(PORTC!=0x0F)
        {
            for(i=0;i<4;i++)
            {
                PORTC=1<<i;
                for(ii=0;ii<16;ii++)
                {
                    if(PORTC==keypad[ii])
                    { 
                        RA3=0; /* led */
                        DelayUs(200);
                        DelayUs(200);
                        RA3=1;
                        i=4;
                        break; 
                    }
                }
            } 
        }
    }
}

If I have it correct, the LED connected to RA3 should briefly switch off when a key is pressed, but nothing happens!!

Please can somebody point me in the correct direction??

Thanks.
 

You messed up the TRISC setting. Take a look at the original code again Sir...
 

Mike said:
You messed up the TRISC setting. Take a look at the original code again Sir...

Thanks, Mike, although it still doesn't work! This one has me a bit stumped.
 

Hi,
I think you have problem exactly here:

"but I am relying on the internat OSC, so I haven't added the XTAL"

simply add XTAL, the problem will be disappear,
regards
 

maybe u should play LED blinking with led at RA3 to conform that the chip can works without Xtal
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top