Shop OBEX P1 Docs P2 Docs Learn Events
converting input pins to a decimal number? — Parallax Forums

converting input pins to a decimal number?

grkblood13grkblood13 Posts: 31
edited 2007-02-20 16:32 in BASIC Stamp
hey, im new to the basic stamp.·I have an A/D converter and·I am trying to find a way to convert a string of high and low signals (P0-P7) into a decimal number. Can any1 help me out with this? Thanks in advance.

Comments

  • BeanBean Posts: 8,129
    edited 2007-01-31 19:50
    What A/D converter are you using ?

    By (P0-P7) do you mean the 8 signals are on pin 0 thru pin 7 (using 8 pin of the basic stamp) ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-01-31 19:56
    Hi grkblood13, if your using P0 to P7 then

    value var byte

    value=INL

    debug DEC value

    Jeff T.
  • grkblood13grkblood13 Posts: 31
    edited 2007-01-31 21:58
    hey, thanks for the help. you made that too easy. i might have some other questions along the way.
  • grkblood13grkblood13 Posts: 31
    edited 2007-02-20 16:10
    hey, i was just wondering what i would need to do to make it (po-p8) other than using the INS command. i want more accurate results so im thinking about going up one more bit but i am also using other pins for other things so i cant use the INS command b/c the other pins will throw the reading off.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-02-20 16:32
    MyWord VAR WORD


    MyWord = INS & $01FF ' This 'masks' off the 'don't care' bits

    ' Note any pins set for 'input' or 'output' will remain set that way.
    ' Any pin set for output will return the value last sent to the 'output latch',
    ' but you mask that value off as a 'don't care'.
    ' But reading that bit won't affect its input/output state, or its value, so
    ' you can do that without having a 'bad effect'.
Sign In or Register to comment.