Shop OBEX P1 Docs P2 Docs Learn Events
4X4 keypad read — Parallax Forums

4X4 keypad read

Brian_BBrian_B Posts: 842
edited 2007-09-23 18:31 in Propeller 1
Hi all,
·I'm trying to read from a 4X4 keypad , it apears that the out pins are floating . Should I be using pull up or pull down resistors on the outputs ! If so what value ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian


www.truckwiz.com

·"Imagination is more important than knowledge..." ·· Albert Einstein

http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-09-23 14:44
    Brian Beckius said...
    Should I be using pull up or pull down resistors on the outputs ! If so what value ?

    (1) Hmmm, all the world takes 10k - so you should also... Funny question...
    (2) up or down - well this depends on the active state of your key presses... That's something only you can know!
    (3) Your code
           if ina[noparse][[/noparse]12] == 1
             number := 10 + index
           if ina[noparse][[/noparse]13] == 1
             number := 20 + index
           if ina[noparse][[/noparse]14] == 1
            number := 30 + index
           if ina[noparse][[/noparse]15] == 1
            number := 40 + index
    


    can be simplified to
      IF INA [noparse][[/noparse]15..12]
         number := INA[noparse][[/noparse]15..12]*10 + index
    
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-09-23 14:50
    Hello!

    Did you really mean to say "out pins are floating"?

    If that is so, you may have to look at the dira register and set output bits high.

    (No, I didn't check your code. I am sure deSilva did)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Brian_BBrian_B Posts: 842
    edited 2007-09-23 15:03
    I'm using 4 outputs to select the row of 4 keys . The program makes one output high and then checks to see if a key is pressed , Then it makes the next output high and checks the keys again . Rigth now when I run the program all the leds randomly go off and on with no keys being pressed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank's Brian


    www.truckwiz.com

    ·"Imagination is more important than knowledge..." ·· Albert Einstein

    http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-09-23 15:41
    OK, a multiplexed keyboard. I asked if it is the output pins you were referring to. You do not need any pull-ups (or -downs) on the Prop outputs. They are not open collector.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • LawsonLawson Posts: 870
    edited 2007-09-23 16:14
    Do you have a pull-down resistor on the input pins of the Propeller? (needs to be a pull down 'cause the rows are driven high) If you don't have something like a pull-down resistor to define the default (off) state of an input it will float to some random value.

    my log($1) cents,
    Marty

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-23 16:40
    Well, before it becomes absolutely confusing here:

    (A) Please connect 10k resistors from GND to pins 12 to 15 of your Propeller ("pull down")
    (B) The code
          dira[noparse][[/noparse] 8..11]~~
    ...
      someloop
    ....
          outa[noparse][[/noparse] 8..11]~
          outa[noparse][[/noparse] index]~~
    


    is no good at all for a simple matrix, as two pressed keys make a shortcut!
    Do
         OUTA[noparse][[/noparse] 8..11] ~~
    ....
      some loop
    ....
          DIRA[noparse][[/noparse] 8..11]~
          DIRA[noparse][[/noparse] index]~~
    


    instead.

    Then it should work!
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-09-23 17:01
    came to think of that old story about the oldest profession - the one that ends in "and who created chaos?"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Brian_BBrian_B Posts: 842
    edited 2007-09-23 18:31
    Sorry for the confusion , I somtimes forget that you guys arn't sitting here looking over my shoulder . deSilva , Works perfect ! Thank's

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank's Brian


    www.truckwiz.com

    ·"Imagination is more important than knowledge..." ·· Albert Einstein

    http://www.diycalculator.com/subroutines.shtml· My favorite website ( Bet you can't guess why)
Sign In or Register to comment.