How to use mag encoder C++


#1

Hello, our team this year is using two motors, TalonSRX and two mag encoders for an elevator system. I am looking through the internet and cant really find any examples on how to take a value for the mag encoders. For example if I wanted to make the motors move up until a certain value, how would I do that. Help would be greatly appreciated. I am using C++ also btw.


#2

Here’s some sample code that you can use.

You can probably ignore the CANifier stuff, and if you would like to you can replace the cout with a statement outputting to the SmartDashboard.