Shop OBEX P1 Docs P2 Docs Learn Events
AW: AW: [basicstamps] inA and for next — Parallax Forums

AW: AW: [basicstamps] inA and for next

ArchiverArchiver Posts: 46,084
edited 2002-08-06 17:18 in General Discussion
helps a very big deal. I love NCD! actually that was the thing I have been
searching for more than once.

THANKS! Uli



Urspr

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-08-06 07:42
    Hi Tracy,

    NCD works great, thanks. But to find out if another sensor is touched at
    vthe same time too I thought of another way. Maybe you could comment on the
    idea and give me some advice?

    OK, lets say sensor No. 5 detects. My puppett will start talking (yes, hold
    my hand...)and that gives me time to check if any other sensor is on too.

    My idea was to check the port again and exclude pin No. 5 by some boolean
    voodoo that you might know about. In other words how could I tell the stamp
    to "read all bits except number five" ? If I could do that I would not have
    to go down to the last bit and repeat the ceremony. If the puppet could say
    "no, please only one hand, not both" that would be OK for a start. If I
    really want to know more I could repeat the routine excluding left AND right
    hand and see if there is more. If so, the puppet would just say, "no please
    take your hands off, lets start once again" .

    I think it should be not to hard to do in boolean logic but of course I
    donot know how :-)

    Thanks, Tracy, and have a nice day!

    Uli





    Urspr
  • ArchiverArchiver Posts: 46,084
    edited 2002-08-06 17:18
    >My idea was to check the port again and exclude pin No. 5 by some boolean
    >voodoo that you might know about. In other words how could I tell the stamp
    >to "read all bits except number five" ?

    You can use a mask to exclude whatever pins you want. A mask like
    $0fff excludes bits 12 to 15, and includes bits 0 to 11. The mask
    can be made to follow the input conditions. For example, in the
    following little program, the mask changes each time you press a
    button, to exlude that button. The program finishes as soon as you
    have press all of the buttons at least once.

    ' pins p0 to p11 go high in respons to buttons
    X var word
    mask var word
    mask=$0fff
    loop:
    debug home,bin12 mask
    X = ins & mask
    mask = mask & ~X
    if mask then loop
    debug "cr,"you have pressed all keys"
    mask


    The mask math goes something like this. Say you first press button #5.
    Then X = %0000000000100000
    Then ~X = %1111111111011111 "`" is stampese for NOT
    When ~X is anded ("&") with the current mask (%0000111111111111), the
    result is mask=%0000111111011111, effectively excluding button 5 from
    the next iteration. Okay, it's a stupid program, but you get the idea.

    -- Tracy
Sign In or Register to comment.