FTC Programming

Servo Control

Here we will learn to program basic servo control.

What is a servo?

A Servo is a rotational motor that can be set to exact positions.

Let's program the Servo

First, we need to set an initial Servo Position. We will do this near all the other motor declarations.

while (opModeIsActive()) {
    double leftPower;
    double rightPower;
    double servoPosition = 0.45;

Now, all that's left is to add code that takes user input to change the servo position. The 'servoPosition' variable will be set by user input (clicking the 'B' button) and will then change the actual servo's position on the robot through the code added previously.

if (gamepad1.a) {
  if (gamepad1.b){