Rotary Hex Dip Switch Code???


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Posts
    4

    Unhappy Rotary Hex Dip Switch Code???

    Can someone give me an idea what the code should look like for reading this type of rotary dip switch. I've looked everywhere and can't find any examples in PBP. The tech. sheets with the switch isn't much help either. I'm using a 16f690 chip and the switch is connected to the 4 port B pins.

    Thanks,

    Dan

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    This is how I would do it:

    - Connect the common (C) pin to +5v
    - Connect the 4 other pins to PORTB.4-PORTB.7
    - Use 10k resistors to pull each of those pins to ground.

    Now all you have to do is this:

    some_variable = ( PORTB & $F0 ) >> 4

    now, some_variable should be equal to the position of your switch.
    Last edited by Kamikaze47; - 13th March 2008 at 13:34.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

Similar Threads

  1. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Rotary encoders
    By mister_e in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st February 2007, 16:57
  5. need hex code to make 12c509 a flip flop,
    By bruce3mn in forum General
    Replies: 1
    Last Post: - 15th November 2004, 03:23

Members who have read this thread : 1

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