Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp switch matrix scan code examples? — Parallax Forums

Basic Stamp switch matrix scan code examples?

Vern GranerVern Graner Posts: 337
edited 2006-04-11 23:35 in BASIC Stamp
I recently encountered a situation where I need to be able to scan eight N.O. switches (one four-direction joystick and four "select" buttons) with a BSII. I originally built a circuit that had each switch on its own pin, which of course consumed eight pins, thinking I had pins to spare.. yeah, I know.. nono.gif

So, of course, I now have need for more pins and it was pointed out on another list that I could use a 2 row by four column matrix for the switches to free up two pins. I've found a good online tutorial on how this is accomplished electronically, but I would like to know if anyone has some basic stamp code examples on how to scan a matrix of this type so I don't have to "re-invent the wheel".

smile.gif

Vern

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
Senior Systems Engineer    | obviously incompetent so why are we
Texas Information Services | paying you? Of course,if the network
http://www.txis.com        | is up, then we obviously don't need
Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-11 18:09
    It might be a bit easier to add a 74x165 (about $1)·to your circuit -- you could use three pins to "scan" the eight switches with one line of SHIFTIN code. Download StampWorks for code and a circuit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Vern GranerVern Graner Posts: 337
    edited 2006-04-11 20:23
    Jon Williams (Parallax) said...
    It might be a bit easier to add a 74x165 (about $1) to your circuit -- you could use three pins to "scan" the eight switches with one line of SHIFTIN code. Download StampWorks for code and a circuit.

    Perfect! I found the Parallax Stamp Works document as a PDF right here and the chip is available from Mouser right here for as low as $0.36! Nice cheap, easy solution. At that price, I can order 10 of them and if some get sacrificed to the smoke diety, I won't cry. turn.gif

    Thanks Jon! smile.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    

    Post Edited (Vern) : 4/11/2006 8:30:28 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-11 23:35
    There's won't be any smoke, Vern, the '165 is easy to use -- and you can daisy-chain 'em to boot!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.