Syntax:
Var = ENCODER( pin1, pin2, LeftLabel, RightLabel , wait)
Remarks:
Var =
The target variable that is assigned with the result
Pin1 and pin2 =
These are the names of the PIN registers to which the output of the encoder is connected. Both pins must be on the same PIN register. So Pinb.0 and Pinb.7 is valid while PinB.0 and PinA.0 is not.
LeftLabel=
The name of the label that will be called/executed when a transition to the left is encoded.
RightLabel=
The name of the label that will be called/executed when a transition to the right is encountered.
wait=
A value of 0 will only check for a rotation/pulse. While a value of 1 will wait until a user actual turns the encoder. A value of 1 will thus halt your program.
There are some conditions you need to fulfill :
• The label that is called by the encoder must be terminated by a RETURN statement.
• The pin must work in the input mode. By default all pins work in input mode.
• The pull up resistors must be activated by writing a logic 1 to the port registers as the examples shows.