Shop OBEX P1 Docs P2 Docs Learn Events
PBASIC2.5 Question — Parallax Forums

PBASIC2.5 Question

breontombreontom Posts: 4
edited 2011-08-25 11:49 in General Discussion
I want to read Pins 0-7 successively in a FOR/NEXT loop, like:

IF IN(i) <>1 THEN . . . . .

I've tried using the PIN directive but have been unsuccessful.

Is there a way to do this?

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-08-24 06:56
    See the STAMP help file for more information on bit aliases.
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    
    aWord   VAR   Word
    aBit    VAR   Byte
    
    aWord = %1010101000001111
    
    FOR aBit = 0 TO 15
      IF aWord.BIT0(aBit) = 1 THEN
        DEBUG "One", CR
      ELSE
        DEBUG "Zero", CR
      ENDIF
      'DEBUG ?aWord.BIT0(aBit)
    NEXT
    
  • breontombreontom Posts: 4
    edited 2011-08-25 11:49
    Thanks. Your code, and the INL command, allowed me to use the pin inputs in a FOR..NEXT loop successfully.
Sign In or Register to comment.