Can you set an alias for an input pin?
jason777
Posts: 11
You can set a contant for an output like this:
RightServo· PIN 12
Can you do so for an input? Like:
IrDetectorLeft·· PIN IN7
This way you dont have to hardcode the number in your code like
FREQOUT 8, 1, 38500
irDetectLeft = IN7
Here, IN7 is hardcoded. I want to declare it at the top in case I changes its location.
Sorry for the noob question.
RightServo· PIN 12
Can you do so for an input? Like:
IrDetectorLeft·· PIN IN7
This way you dont have to hardcode the number in your code like
FREQOUT 8, 1, 38500
irDetectLeft = IN7
Here, IN7 is hardcoded. I want to declare it at the top in case I changes its location.
Sorry for the noob question.
Comments
-Phil
Here is an article on the PIN declaration, including possible special or ambiguous situations. It includes some correspondence with Jeff Martin about the compiler rules.
You can also declare the aliases in the old (pre PBASIC 2.5) way:
outPin CON 7 ' output references like HIGH outPin
outBit VAR out7 ' output references like outBit=1
inBit VAR in8 ' input references to inPin will use in8, x=inBit
or new (PBASIC 2.5):
myPin PIN 7 ' for either output or input, depending on context
At compile time, each instance of myPin in the program is resolved to one of the "old" type of references, as appropriate in context. There is a set of rules that the compiler uses to make that decision.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com