Shop OBEX P1 Docs P2 Docs Learn Events
Multiple Button Inputs via Really Simple Binary Encoding - Newbie Question — Parallax Forums

Multiple Button Inputs via Really Simple Binary Encoding - Newbie Question

Rex RhinoRex Rhino Posts: 4
edited 2006-04-30 08:08 in BASIC Stamp
Hello, I am a newbie and not much of an electronics expert, so please forgive me if my question is a bit silly.

I want to interface a lot of momentary push buttons into a basic stamp... Lets say 64 buttons. None of these buttons will be pressed simultaniously (and they are only being used to trigger sound effects on a chipcorder chip, so it wouldn't be a disaster if some were pressed simultaniously... there is no highly critical industrial automation happening here or anything! lol.gif )

Can I simply wire one side of the button to ground, and then wire the other side to several input pins, to binary code each button? I realize that it would be a lot of work to connect each button, and that it would not function properly if buttons are pressed simultaniously... But is there anything fundamentally wrong with this approach?

Is there any other extremly simple way to accomplish this?

Thanks!
Rex Rhino

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-30 04:59
    Rex -

    This is a very interesting, and not uncommon quandry for a newcomer. How about I start your thinking out, and you try to expand on it? I honestly can't think of a better way to learn about things like this.

    The number you have chosen has a very interesting quality about it - 64. What is the square root of 64, and is it even?

    How might you use this interesting quality to your advantage? HINT: Think in terms of 2 dimensions, or a matrix.

    Homework: Investigate 8-bit Parallel In, Serial Out Shift Registers and ponder how they might be used in an application like this.

    Just as an aside, there is no single "correct" solution to your problem. There are numerous solutions, and your job will be to pick the one most appropriate to your needs.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 4/30/2006 5:08:16 AM GMT
  • Rex RhinoRex Rhino Posts: 4
    edited 2006-04-30 05:47
    Thanks for you help bruce! I appreciate it.

    I am not sure if I would use Serial In, as I would not be taking input from a serial device...

    Here is how I would do things. In the main program loop, I would examine the PINS or INS variable (depending on stamp version), and use the first 6 bits as my button input. Each button would be wired to pins 0-5 in such a way as to represent each button as a binary number (for example, button 10 would be wired to pin1, and pin3 (starting from zero going up) to represent 10 in binary). I could use the 7th pin as a "confirm that the button is in fact being pressed" pin, or just have 63 buttons and have 0 mean no buttons are pressed.

    Programming wise, this seems best to me, and programming wise, I know it will work.

    The question I have, is that is there electrical issues that I don't know about? I want to use arcade cherry buttons, and having 64 of these wired up to several pin terminals... is this a wise thing to do? Logically, it makes sense... I know if I was using an 8 bit DIP switch instead of 64 cherry buttons, it would work flawlessly. But before I buy 64 cherry buttons, and the hardware to wire them up in binary code, I just want to make sure I am not making a stupid mistake! [noparse]:)[/noparse]
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-04-30 08:08
    Theres no serious electrical issues involved, the easiest way to connect them is doing what Bruce suggested and hook them up like an 8x8 keypad. Doing this, you should only need a couple chips and only need to use 4-5 pins on your Stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10
Sign In or Register to comment.