Shop OBEX P1 Docs P2 Docs Learn Events
How to read a switch — Parallax Forums

How to read a switch

ArchiverArchiver Posts: 46,084
edited 2001-03-09 03:02 in General Discussion
I am using the BS2 and want to use 2 I/O pins for
connection to a switch. This switch will be used as a
table selection. The following is the truth table;

SW1 SW2 Table Selected
0 0 0
0 1 1
1 0 2
1 1 3

What I want to do is read the logic state of these two
inputs and have the software use the proper lookup
table.

Thanks for any help

John

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-03-08 14:18
    On Thu, 08 Mar 2001, John DeFeo wrote:

    > I am using the BS2 and want to use 2 I/O pins for
    > connection to a switch. This switch will be used as a
    > table selection. The following is the truth table;
    >
    > SW1 SW2 Table Selected
    > 0 0 0
    > 0 1 1
    > 1 0 2
    > 1 1 3
    >
    > What I want to do is read the logic state of these two
    > inputs and have the software use the proper lookup
    > table.
    >
    > Thanks for any help
    >
    > John
    >

    would this work?

    switches var nib

    switches = in1 << 1 | in2

    branch switches, [noparse][[/noparse]action0, action1, action2, action3]
  • ArchiverArchiver Posts: 46,084
    edited 2001-03-09 03:02
    Thanks for the input.


    --- Mike Eggleston <mikee@m...> wrote:
    > On Thu, 08 Mar 2001, John DeFeo wrote:
    >
    > > I am using the BS2 and want to use 2 I/O pins for
    > > connection to a switch. This switch will be used
    > as a
    > > table selection. The following is the truth table;
    > >
    > > SW1 SW2 Table Selected
    > > 0 0 0
    > > 0 1 1
    > > 1 0 2
    > > 1 1 3
    > >
    > > What I want to do is read the logic state of these
    > two
    > > inputs and have the software use the proper lookup
    > > table.
    > >
    > > Thanks for any help
    > >
    > > John
    > >
    >
    > would this work?
    >
    > switches var nib
    >
    > switches = in1 << 1 | in2
    >
    > branch switches, [noparse][[/noparse]action0, action1, action2,
    > action3]
    >
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >


    __________________________________________________
    Do You Yahoo!?
    Get email at your own domain with Yahoo! Mail.
    http://personal.mail.yahoo.com/
Sign In or Register to comment.