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.

matrix keyboard not working with pic16f877a ??

Status
Not open for further replies.

rangerskm

Full Member level 4
Full Member level 4
Joined
Jan 23, 2013
Messages
199
Helped
0
Reputation
2
Reaction score
0
Trophy points
1,296
Visit site
Activity points
2,663
i tried to connect the matrix keyboard with pic16f877a .but its not working i dont know the mistakes in it.i used the internal pull up of pic ,but no use .can any one guide me in that

//4 * 4 MATRIX CONNECTION FOR 4* 3 SWITCHES
//starting from on- 1 to 12





#include<pic.h>
#define _XTAL_FREQ 20000000
#define SEND_SER(data) TXREG=data+48;while(!TRMT);
uartinit();
int flag;

void main()
{
TRISB=0XF0; // 4 lsb output and 4 msb inpt
PORTB=0X0F;//4 lsb outputs hgh and msb inputs low
//nRBPU=0;
TRISD=0X00;
PORTD=0X00;
uartinit();
while(1)
{
PORTB=0XF7;//for checking switch 1 2 3
if(RB4==0)

{
__delay_ms(100);
while(RB4==0);
__delay_ms(100);
PORTB=0XFF;
SEND_SER(1);

}
if(RB5==0)
{ __delay_ms(150);
SEND_SER(2);
PORTD=0X00;
}
else if(RB6==0)

{
__delay_ms(150);
SEND_SER(3);
}
PORTB=0XFB;//for checking switch 4 5 6

if(RB4==0)
{
__delay_ms(150);
PORTD=0X00;
SEND_SER(4);

}
if(RB5==0)
{

__delay_ms(150);
PORTD=0X00;
SEND_SER(5);

}
if(RB6==0)
{
__delay_ms(150);
SEND_SER(6)
}
PORTB=0XFD;//for checking switch 7 8 9
if(RB4==0)
{
__delay_ms(150);
SEND_SER(7)
}
if(RB5==0)
{
__delay_ms(150);
SEND_SER(8)
}
if(RB6==0)
{
__delay_ms(150);
SEND_SER(9)
}
PORTB=0XFE;//for checking switch 10 11 12
if(RB4==0)
{__delay_ms(150);
SEND_SER(0)
}
if(RB5==0)
{
__delay_ms(150);
SEND_SER('a'-48)
}
if(RB6==0)
{__delay_ms(150);
SEND_SER('b'-48)
}


}

}
uartinit()
{
SPBRG=129;
BRGH=1;
SYNC=0;
SPEN=1;
TXEN=1;
}
 

The algorithm above is not the usual one commonly used to scan matrix keyboards.
Take a look on options bellow:











+++
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top