3x4 keypad help

Discussion in 'Embedded Systems and Microcontrollers' started by andrei_w, Jun 6, 2010.

  1. andrei_w

    Thread Starter New Member

    Jun 6, 2010
    9
    0
    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.


    Code ( (Unknown Language)):
    1.  
    2. DDRC= 0b11110000;
    3. PORTC=0b00001111;    
    4.    while(1)
    5.    {
    6.    PORTC = 0b11101111;
    7.  
    8.   if (!bit_is_set(PINC, 1))
    9. { glcdSetAddress(3,LINE6);
    10.   glcdPutStr("1");}
    11.   if (!bit_is_set(PINC, 3))
    12. { glcdSetAddress(3,LINE6);
    13.   glcdPutStr("2");}
    14.   if (!bit_is_set(PINC, 2))
    15. { glcdSetAddress(3,LINE6);
    16.   glcdPutStr("3");}
    17.  
    18.    PORTC = 0b11011111;
    19.  
    20.   if (!bit_is_set(PINC, 1))
    21. { glcdSetAddress(3,LINE6);
    22.   glcdPutStr("4");}
    23.   if (!bit_is_set(PINC, 3))
    24. { glcdSetAddress(3,LINE6);
    25.   glcdPutStr("5");}
    26.   if (!bit_is_set(PINC, 2))
    27. { glcdSetAddress(3,LINE6);
    28.   glcdPutStr("6");}
    29.  
    30.       PORTC = 0b10111111;
    31.  
    32.   if (!bit_is_set(PINC, 1))
    33. { glcdSetAddress(3,LINE6);
    34.   glcdPutStr("7");}
    35.   if (!bit_is_set(PINC, 3))
    36. { glcdSetAddress(3,LINE6);
    37.   glcdPutStr("8");}
    38.   if (!bit_is_set(PINC, 2))
    39. { glcdSetAddress(3,LINE6);
    40.   glcdPutStr("9");}
    41.  
    42.    PORTC = 0b01111111;
    43.  
    44.   if (!bit_is_set(PINC, 1))
    45. { glcdSetAddress(3,LINE6);
    46.   glcdPutStr("0");}
    47.   if (!bit_is_set(PINC, 3))
    48. { glcdSetAddress(3,LINE6);
    49.   glcdPutStr(")");}
    50.   if (!bit_is_set(PINC, 2))
    51. { glcdSetAddress(3,LINE6);
    52.   glcdPutStr("(");}
    53.  
    54.  
     
  2. hgmjr

    Moderator

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

    hgmjr
     
  3. andrei_w

    Thread Starter New Member

    Jun 6, 2010
    9
    0
    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

    [​IMG]

    [​IMG]

    [​IMG]
     
    Last edited: Jun 6, 2010
  4. hgmjr

    Moderator

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

    hgmjr
     
  5. andrei_w

    Thread Starter New Member

    Jun 6, 2010
    9
    0
    Ok. I put the pictures into the zip file. Thanks
     
  6. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    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.
     
  7. andrei_w

    Thread Starter New Member

    Jun 6, 2010
    9
    0
    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
     
  8. andrei_w

    Thread Starter New Member

    Jun 6, 2010
    9
    0
    any ideas?
     
Loading...