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.

interfacing 8x4 matrix keypad with atmega

Status
Not open for further replies.

mythrikalam

Newbie level 6
Joined
Oct 4, 2010
Messages
14
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
INDIA
Activity points
1,398
can anyone suggest me how to interface the 8x4 matrix keypad with atmega.
if anyone had any suggestable program kindly pass it to me....
 

8x4 keypad will require atleast 12 i/o lines of the controller. Considering the fact that atmega series have 8 bit micro controllers and correspondingly the i/o ports are 8 bit wide. Hence the program will be some what lengthy but not complicated. Refer to the mazidi book of AVR micro controllers. It has got an example of interfacing 4x4 matrix keypad. Your case is just and extension of that example.
 

8x4 keypad will require atleast 12 i/o lines of the controller. Considering the fact that atmega series have 8 bit micro controllers and correspondingly the i/o ports are 8 bit wide. Hence the program will be some what lengthy but not complicated. Refer to the mazidi book of AVR micro controllers. It has got an example of interfacing 4x4 matrix keypad. Your case is just and extension of that example.

yes...it needs 12 i/o lines and it is 8 rows connected to one port and 4 columns connected to the other port. I had tried extending the code of 4x4 matrix kepad code but it is not working.....
 

Ok, so now its the trouble shooting time. There are plenty of things to check if all the silly mistakes are accounted for but I ll get you started. Before that, I need to know, whats your output i.e. how do you know that button presses are not being recognized by the controller??
 

Ok, so now its the trouble shooting time. There are plenty of things to check if all the silly mistakes are accounted for but I ll get you started. Before that, I need to know, whats your output i.e. how do you know that button presses are not being recognized by the controller??

when a key is pressed, a corresponding value has to be displayed on the GLCD but in against to when a key is pressed for the first time one value is displayed and if you press the same key for the next time some different value is being displayed and if continue to press the same key continuously it continuously displays the different values.

int get_key() //function declaration for assigning the values for keys
{ int i,key_value=1;//declaration of unsigned characters i,key
for(i=0;i<8;i++)
{ PORTC |= 0xf0;
PORTC &= ~(0x80>>i);//Make rows low one by one
_delay_us(1); //Wait before reading port
if(!(PINC & (1<<PC0)))//if the condition is true assign key a value
{ while(!(PINC & (1<<PC0)));//while the condition is true always
return key_value; //return the value of key
}
if(!(PINC & (1<<PC1)))//if the condition is true assign key a value
{ key_value += 1;//defining the required value of key
while(!(PINC & (1<<PC1))); //while the condition is true always
return key_value; //return the value of key
}
if(!(PINC & (1<<PC2))) //if the condition is true assign key a value
{ key_value += 2; //defining the required value of key
while(!(PINC & (1<<PC2))); //while the condition is true always
return key_value; //return the value of key
}
if(!(PINC & (1<<PC3)))//if the condition is true assign key a value
{ key_value += 3; //defining the required value of key
while(!(PINC & (1<<PC3))); //while the condition is true always
return key_value; //return the value of key
}
key_value +=4;//defining the required value of key
}
return(0); //returning 0
}
 

Firstly, I havent worked on GLCD's yet so I dont really know how are they operated. Secondly, take things slow and step by step when you get stuck. I suggest you disconnect the LCD for now and place LED's at some port. Such that, the number you press gets output at that LED port. In this way you ll break down a much complicated problem in to a simpler one. Maybe the problem lies with the LCD programming or hardware.

If the LED test comes out to be good then proceed with connecting the LCD. But, if problem lies with the keypad part then you have a simple setup to work with and trouble shoot.

Have you provided provision for 'button de-bouncing'??
 

GLCD is not at all a problem either regarding hardware or the software........only problem is with the code that we use it for 8x4 keypad.....if that code is used for 4x4 keypad having connected to same port, it works.but for 8x4 rows has to be connected to one port and columns to the other and now it is a problem with functioning of code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top