How to declare a quadrature encoder in V5 Text

How are Quadrature encoders declared in vexcode v5 text? I want to declare them physically as a line of code, not in the separate panel.

Add this to robot-config.cpp

encoder EncoderA = encoder(Brain.ThreeWirePort.A);

and this to robot-config.h

extern encoder EncoderA;

You can change EncoderA to whatever name you like and select the pair of brain ports by changing the three wire port.A to A, C, E, G. The encoders only work with pairs that are right next to each other such as A and B or E and F.

4 Likes

Also, please, see this notice: Instantiation of a shaft encoder causing an error - #2 by jpearman

2 Likes