Shop OBEX P1 Docs P2 Docs Learn Events
stupid question ... — Parallax Forums

stupid question ...

bkibabkiba Posts: 17
edited 2007-05-10 01:11 in BASIC Stamp
How would one go about setting up the basic stamp (BS2PE or BS2) to detect if a switch is thrown. I'm not talking about the 4 pin switches that come with the kits, I'm talking about a regular on off switch, with 2 pins.

I have a 4 key, illuminated key pad. two pins are for the LEDs, so + and - for those. Then there are 5 more pins, a common pin and a pin hooked to each individual key. When a key is pressed and held, the pin for that key and the common short. I'm trying to use the IN# command and debug the IN0, IN1, IN2, IN3 that I have the key pins hooked too, but it seems like whenever I press a key, the IN0-IN3 values randomly decide what they will be, with no repeatability.

Thanks

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2007-05-09 02:41
    bkiba,

    "...When a key is pressed and held, the pin for that key and the common short. I'm trying to use the IN# command and debug the IN0, IN1, IN2, IN3 that I have the key pins hooked too, but it seems like whenever I press a key, the IN0-IN3 values randomly decide what they will be..."

    If the "common pin" is GND, you need to use a pull-up resistor to Vdd with a value somewhere between 1K and 100K on each "pin for that key".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • willy1067willy1067 Posts: 107
    edited 2007-05-09 02:50
    Bkiba,

    Keypads usually don't have each key attached to a pin, The first thing you should do is find the schematics for the key pad you are using, (googgled) or find the manufacturer web site.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fernando Gomez

    revinc.us
    gomez-rivera.com

    Never compare yourself with anyone else, there will always be someone bigger·or·smaller·than you.
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-05-09 16:18
    Do you get a random key in no matter which one you push or do you get the right key with a random value? It could be a bounce problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • bkibabkiba Posts: 17
    edited 2007-05-10 00:17
    Thanks for the suggestions.

    The keypad is a storm backlit 4 button keypad.

    It has a 7 pin connector

    pin 1 - Cathode for LED
    pin 2 - common
    pin 3 - key D
    pin 4 - key C
    pin 5 - key B
    pin 6 - key A
    pin 7 - anode for LED

    I've been pretty successful so far with electronics, I've never actually had a course or training on this stuff, so could you please explain what a pull up resistor is? Are you saying each pin 3-6 needs a resistor or just the ground/common pin?

    thanks again!
  • phil kennyphil kenny Posts: 233
    edited 2007-05-10 01:11
    Using Google for 'pull up resistor' brought this link up as the first one:

    www.seattlerobotics.org/encoder/mar97/basics.html

    Pull up resistor is the first topic discussed.

    Good basic tutorial on electronics.

    phil
Sign In or Register to comment.