Help: how to assign assorted pins to one byte variable


Results 1 to 9 of 9

Threaded View

  1. #3
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Help: how to assign assorted pins to one byte variable

    Congrats on your Efforts of working on your Eagle Scout !!

    You know it would help if I really read the question, the following is how I did an INPUT from a DIP Switch.

    I did this using a 12f683 -- needed the _MCR working otherwise GPIO.3 would of been handy.
    12f683 has 6 I/O pins

    Code:
    DIP_ =  (gpio & $07) + (GPIO.4 * $08)  ' Read GPIO.0.1.2.4 & MAKE IT BCD /hex4
    I was going to give you the code, but since it is for your Eagle project I will give you HINTS.
    ** If you are stumped then message me and I will gladly give you the code - you can do it in 3 lines **

    HINTS
    0. Store the final value you want in a BYTE VAR ... LED_OUT
    1. Extract the bits for each part using LED_OUT & %00000011 .... ???
    2. Shift the result up or down to where you need them; using ">>" [hint use parentheses to keep things tidy]

    Code:
    PORTx= LED_OUT &  %00000011 .... ???
    Last edited by ofuzzy1; - 6th March 2011 at 01:35.

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