Two switches per pin!!!


Results 1 to 5 of 5

Threaded View

  1. #1

    Thumbs up Two switches per pin!!!

    Hello,

    I'm sure that many people here have already used this method but, if not, here is a way to detect two switches on one pin.

    Why would you want to do this?

    If you've ever had to upgrade to a larger, more expensive chip because you needed a couple more input pins, you'll see the benefit.

    Assuming you're already using one resisitor per switch to bias them to VCC or GND (you should be), this method only adds one extra resistor for every two switches. Fractions of a penny.

    The only requirement is that you must be able to configure your input pin as analog. This will not work on "digital only" I/O pins.

    It works by using a voltage divider. When neither switch is pressed, you get VCC. When switch 1 is pressed you get a unique voltage. When switch 2 is pressed you get another unique voltage. If you press switch 1 and switch 2 at the same time you will get a 3rd unique voltage.

    It starts to get kind of sketchy when you try and hook up more than two switches to one input pin. So, unless there is no way that the user can press more than one switch at a time, I wouldn't recommend it.

    I've attached a small application (zipped up) that includes a simple schematic and allows you to fool around with different resistor values.

    You want to choose resistor values that keep each of the 4 different voltages as far apart (spread out) in value as you can, so that you don't misread which switch has been pressed.

    Enjoy!
    Attached Files Attached Files
    Last edited by picnaut; - 16th June 2004 at 02:03.
    ---> picnaut

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 05:07
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts