How to use analog output
Last updated
Last updated
// Get analog port instance from hardwareMap
AnalogInput encoder = hardwareMap.get(AnalogInput.class, "encoder");
// Simple position return
double position = encoder.getVoltage() / 3.2 * 360;
// Position return with adjustable offset
// Offset must be positive, otherwise the modulo (%) operation breaks
//
// If you want to use a negative offset, just add some multiple of 360 so
// that the offset evaluates to be positive.
double offset = -123.4 + 360;
double offsetPosition = (encoder.getVoltage() / 3.2 * 360 + offset) % 360;