what is Ins.LowBit
yzche
Posts: 35
following code is from IR buddy manual
If(Ins.LowBit(pin)=0)
what is Ins
what is LowBit
what does Ins.LowBit mean?
is 0 then only option?
·
If(Ins.LowBit(pin)=0)
what is Ins
what is LowBit
what does Ins.LowBit mean?
is 0 then only option?
·
Comments
(You have to have SET the pin as an input to actually read the signal on the
·pin, otherwise you'll read the signal the BS2 is putting out on the pin.)
.LowBit (aka .BIT0) is the lowest pin on the INS variable -- aka IN0.
So the line you're asking about reads the state of P0 as an Input,
and checks to see if it is zero (ie ground, ie zero volts).· It could
also be a 1 (ie +5 volts).
·
Ins.LowBit refers to the lowest bit of Ins, otherwise known as In0.
The Stamp has several different ways to refer to the same bit. Another way is Ins.bit0. Another is InL.lowbit. Another is InA.bit0. These names are very systematic and are described in the manual and in the help file.
Ins.Lowbit(0) is yet another way to refer to in0, but with an array index.
Ins.LowBit(1) is the same as in1
Ins.LowBit(2) is the same as in2
etc
You might ask why go to so much trouble? Precisely because it lets you use an array index (the variable or constant "pin" in the example). By the way, they could have written it as,
IF in0(pin) = 0 THEN ...
which is the same as
IF (Ins.LowBit(pin) = 0) THEN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
we can do this:
Because the version 2.1 compiler can resolve the PIN definition to the INS variable for us.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office