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.

Key pad scaning pRog..HELP

Status
Not open for further replies.

thecall

Junior Member level 2
Joined
Mar 4, 2007
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,448
i wrote this prog for scanning key pad and displaying no on 7 seg display.i am using 2 rows and 2 col key pad. connected to RB4,RB5,RB6,RB7

and 7SEG connected to RA2,RA3,RA4,RB0,RB1,RB2,RB3


Now the problem is that how to on 7 seg like it s hlfly connected to port a and portb.

here is the prog



#define ROW1 portB.F6
#define ROW2 portB.F7
#define COL PORTB.F5
#define COL2 PORTB.F4

unsigned char scankeypad()
{
ROW1=0;
if(COL==0)
return 0x00;
else if (COL2==0)
return 0x01;
else;

ROW2=0;
if(COL==0)
return 0x04;
else if(COL2==0)
return 0x05;
else;
return 255;

}

void main()
{
unsigned char n[]={0x01,0x02,0x04,0x05} ;
TRISB.F4=1;
TRISB.F5=1;
TRISB.F6=1;
TRISB.F7=1;
TRISB.F1=0;
TRISB.F2=0;
TRISB.F3=0;
TRISA.F2=0;
TRISA.F3=0;
TRISA.F4=0;


unsigned char key=0;
key=scankeypad();
if (key==255)
{
continue;
}
else{
PORTB=n[key];
break;
}

}



 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top