Shop OBEX P1 Docs P2 Docs Learn Events
new user multi input help required — Parallax Forums

new user multi input help required

staffshomestaffshome Posts: 28
edited 2009-09-09 11:21 in BASIC Stamp
Hi,
can anyone help me with how to read 4 input pins
from table below,inputs from switch are multiplexed,how do i read all 4 inputs & run a subroutine for
each of the six input statements.Looked in manual & got totally confused,i think i need a lookup table ?
switch Table:
input pin ·5·6 7 8
· gear··· ·A B C PA
······· P = 1 0 0 1
········R= ·1 1 0 0
········N= ·0 1 0 1
········D= ·0 1 1 0
········3=· 1 1 1 1
······· L=· 1 0 1 0
·using BS2Px board & pbasic 2.5

Thanks Adrian

Comments

  • dev/nulldev/null Posts: 381
    edited 2009-09-09 11:01
    Something like this?

    mynib VAR Nib
    
    mynib.BIT0 = IN5
    mynib.BIT1 = IN6
    mynib.BIT2 = IN7
    mynib.BIT3 = IN8
    
      SELECT mynib
        CASE %1001 : GOSUB A
        CASE %1100 : GOSUB B
        CASE %0101 : GOSUB C
        CASE %0110 : GOSUB D
        CASE %1111 : GOSUB E
        CASE %1010 : GOSUB F
      ENDSELECT
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • staffshomestaffshome Posts: 28
    edited 2009-09-09 11:21
    Thank you,

    Looks like the answer

    regards Adrian
Sign In or Register to comment.