Shop OBEX P1 Docs P2 Docs Learn Events
7 segments display using 3X4 Keypad — Parallax Forums

7 segments display using 3X4 Keypad

I need some help with my project. I'm planning to use a 3x4 keypad and a display with 2 7segments. The plan is to display in the 7segments the number what is press in the keypad.

i am using COM-08653 keypad ... my columns are connected to P0,P1,P2... my rows are connected to P3,P4,P5,P6.

attached is the connection layout

Thanks
999 x 655 - 19K

Comments

  • BeanBean Posts: 8,129
    Not sure exactly what part of the project you need help with ??? I will assume it is reading the keypad.

    You have pull-downs on the columns, so that means you will want to make each of the rows high (1 at a time) and see if any of the columns go high. If any of them do, then the key that connects the row (that you made high) and the column (that you read as high) must be pressed.

    So basically you will make P0 high and P1 & P2 inputs (don't make them LOW because if more than one key is pressed you could get a short). Then read the P3 thru P6 pins to see if any are high.
    Then make P1 high and P0 & P2 inputs, and read pins P3 thru P6 again, and so on...

    I hope that makes sense. Please let us know if this is helpful.

    Bean
  • kwinnkwinn Posts: 8,697
    How are you driving the 7 segment displays? Each of the segments from a separate pin or multiplexed?
  • each from a separate pin

  • the thing is that i am new to using BS2... the test project starts with reading the 7 segment display with 5 seconds pause between readings ( i am using p9-p15)... the second part requires adding the key pad and display readings through it ... the test project continue like this adding a new part every time ... i read about the subject and i found several codes on the internet. however not being an expert in BS2 i couldn't manipulate them to suite my key pad connection (can't change it)
  • Bean, could you please give me an example on how to do so on programming.
  • tomcrawfordtomcrawford Posts: 1,129
    edited 2016-04-04 23:03
    rosco_pc wrote: »

    I'm afraid this code really won't work with the keypad rania has. It is intended for a keypad with series resistors, not resistors to ground (also it is 4x4 not 4x3 and wired differently). Bean explained exactly what rania has to do; he simply needs to translate it to BS2 code.

    Edit: Actually, I think Bean got it wrong, too. His detailed description has rania driving the columns and sensing the rows. He should drive the rows (P3..7) and sense the columns (p0..2). This is because the pulldowns are on the columns.
    Pad   var  word
    Row  var  nib
    
    ReadKeyPad:
      Pad = 0
      Input 3
      input 4
      input 5
      input 6
      for Row = 0 to 3
          high (row + 3)                  'drive one row
          Pad = (Pad << 3) | (ina & %111)    'shift and combine
          input (row + 3)
          next
        return
    
  • BeanBean Posts: 8,129
    Tom, you are correct. Drive the rows and sense the columns. Sorry about that...
  • tomcrawford, thanks for your help ... so this routine shall scan my keypad. how can i debug to see the pressed key?
  • raniarania Posts: 12
    edited 2016-04-12 05:00
    :)
  • my next step is to try to control the 7 segments display using this keypad ... attached is the connection


    Many thanks for all of you ...
    1427 x 935 - 112K
  • raniarania Posts: 12
    edited 2016-04-12 04:59
    and this is how my final code looks like :

    ' ay to do it.
  • now if * is pressed i should exit the program ... what is the statement to do so
  • The statement to end program is
    END
    
  • The statement to end program is
    END
    

    many thanks
  • raniarania Posts: 12
    edited 2016-04-07 17:35
    back again: i am really progressing with the code ... now i have to do the following :
    2. Program the Microcontroller to do the following:
    a. The green LED will turn ON, show letter “r” on the display
    b. Wait until * key is pressed and released. Nothing should happen if any key is held pressed.
    c. When * key is released, the green LED will turn off and red LED will turn on, letter “t” will be shown on the display, and the Microcontroller will wait until any numeric key between “1 and 9” is pressed and released.
    d. When any numeric key between “1 and 9” is released, the Microcontroller will wait until “#” key is pressed and released.
    e. When “#” key is released, the Microcontroller will count down starting from the number pressed to “0”. Each count will be displayed for 1 second.
    f. When Microcontroller finishes counting down, the program will start over again waiting for the user to press * key with the green LED turned on and red LED off.

    I am trying to execute actions when a key is pressed then released not while still pressed. i tried to save old status (pressed) and new one (released) but it did not work ..i tried to use the release sub routine in the code above yet i couldn't get it to function as intended
  • When there are no keys pressed, ReadKeyPad will return zero.
  • i tried by adding the changes to the release sub:

    Released:
    oldKey = 100
    LOW 7
    OUTH = %11110000
    HIGH 8

    however this will apply the changes whenever a key is released while i need the changes to apply only if * key is released
  • rania wrote: »
    i tried by adding the changes to the release sub:

    Released:
    oldKey = 100
    LOW 7
    OUTH = %11110000
    HIGH 8

    however this will apply the changes whenever a key is released while i need the changes to apply only if * key is released

    Then you will need to test (presumably inside the release subroutine) whether the key that was released is the * key.
Sign In or Register to comment.