3x4 keypad help

Thread Starter

andrei_w

Joined Jun 6, 2010
9
Hello guys. I'm new in programming and I have a problem with a 3x4 keypad. I have found a code on the internet for a 4x4 keypad and I have aplyed this code a little bit modified to my project but I can't read a column. It looks like only two if conditions are read. The values are showed on a glcd.Please help me
The columns are connected to PC1, PC2, PC3 and the rows are connected to PC4,PC5,PC6,PC7. I'm using atmega 32. A guy told me that I should put a longer delay because the response of AVR inputs is delayed by one cycle but i don't now where do i should put the delay, because in my code I don't have any delay.


Rich (BB code):
DDRC= 0b11110000; 
PORTC=0b00001111;    
   while(1) 
   { 
   PORTC = 0b11101111; 

  if (!bit_is_set(PINC, 1)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("1");} 
  if (!bit_is_set(PINC, 3)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("2");} 
  if (!bit_is_set(PINC, 2)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("3");} 

   PORTC = 0b11011111; 

  if (!bit_is_set(PINC, 1)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("4");} 
  if (!bit_is_set(PINC, 3)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("5");} 
  if (!bit_is_set(PINC, 2)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("6");} 

      PORTC = 0b10111111; 

  if (!bit_is_set(PINC, 1)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("7");} 
  if (!bit_is_set(PINC, 3)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("8");} 
  if (!bit_is_set(PINC, 2)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("9");} 

   PORTC = 0b01111111; 

  if (!bit_is_set(PINC, 1)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("0");} 
  if (!bit_is_set(PINC, 3)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr(")");} 
  if (!bit_is_set(PINC, 2)) 
{ glcdSetAddress(3,LINE6); 
  glcdPutStr("(");}
 

hgmjr

Joined Jan 28, 2005
9,027
It would clarify things for our members if you would go ahead and post the schematic for our benefit.

hgmjr
 

Thread Starter

andrei_w

Joined Jun 6, 2010
9
I put here 3 pictures. Only keyboard.jpeg represents only the keypad and the atmega because the schematics of the atmega + the rest of my project components it's a little bit hard to watch. Anyway i put the schematics of the atmega & GLCD in the second picture. In this schematics I have 6 buttons, 2 switches and the free pins are putted to a con. This schematics it isn't important because my glcd is working very good and now i make an upgrade with keypad. In the 3rd picture i put the datasheet of te keypad





 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
Under "Go advanced" feature (not quick reply) you will find a manage attachment button. Click on that button and the rest is straightforward.

hgmjr
 

John P

Joined Oct 14, 2008
2,026
I'm a PIC guy and I don't know that processor, but one thing I don't see on the diagram is pullup resistors for any of the keyboard lines. On a PIC could be done by internal pullups, and maybe your processor can do the same, but one way or another, you have to have them.
 

Thread Starter

andrei_w

Joined Jun 6, 2010
9
I have putted pull up resistors in practice but I have forgotten to figure them in schematics. But also I have internal pull ups on each pin
 
Top