PDA

View Full Version : PBASIC2.5 Question



breontom
08-24-2011, 12:51 PM
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?

Mike G
08-24-2011, 01:56 PM
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

breontom
08-25-2011, 06:49 PM
Thanks. Your code, and the INL command, allowed me to use the pin inputs in a FOR..NEXT loop successfully.