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.

[SOLVED] simple interfacing of 4x3 keypad

Status
Not open for further replies.

eeHassan

Member level 2
Member level 2
Joined
Jan 28, 2011
Messages
52
Helped
0
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Lahore, Pakistan
Activity points
1,615
Hey,
I want to interface a simple 4x3 keypad with 89c51....how can i do that without using any encoder?
 

if you have 7 spare digitial IO lines you connect the 3 columns and 4 rows and decode the key presses in software. If you search the forum you should find plenty of examples of circuits and code.
 

This is a very useful Microcontroller Interfacing Techniques file

Best Regards

MedTronic
 

Attachments

  • micro_interfacing.pdf
    396.4 KB · Views: 226

Check out this implementation :


#define LINES 0x0F
#define ROWS 0xF0

unsigned char ScanKey ( void )
{
unsigned char ReadingKey = 0 ;

MicrocontrollerOutput = LINES;
Delay(4) ;
ReadingKey = (~( MicrocontrollerOutput | ROWS )) ;
if ( ReadingKey )
{
MicrocontrollerOutput = ROWS ;
Delay(4) ;
ReadingKey += (~( MicrocontrollerOutput | LINES )) ;
return ( ReadingKey ) ;
}
else return ( NO_KEY ) ;
}

Note that Low nible pins of port read High pins of port and vice-versa.

The constraint are :
1 ) keyboard pins of uC must be at an entyre port ( i.e.: P3 )
2 ) Doesn´t work by interrupt.

The big advantage is :
You can map a wide combintions of simultaneous pins pressed ( like CTRL or SHIFT function )

+++
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top