-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleMyBlocks_v01.java
More file actions
28 lines (22 loc) · 1.27 KB
/
Copy pathSampleMyBlocks_v01.java
File metadata and controls
28 lines (22 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.firstinspires.ftc.teamcode;
import org.firstinspires.ftc.robotcore.external.BlocksOpModeCompanion;
import org.firstinspires.ftc.robotcore.external.ExportToBlocks;
import com.qualcomm.robotcore.hardware.Servo;
public class SampleMyBlocks_v01 extends BlocksOpModeCompanion {
@ExportToBlocks (
comment = "Move a conventional servo back and forth. Assumes servo starts" +
" from position 0. Servo name must be in the active configuration.",
tooltip = "Wiggle a user-designated servo.",
parameterLabels = {"Servo name", "Duration (milliseconds)", "Number of cycles"}
)
public static void wiggleServo (String servoName, int duration, int cycles) {
Servo myServo = hardwareMap.get(Servo.class, servoName);
// count up to 'cycles' AND while opMode was not stopped
for (int i = 0; i < cycles && linearOpMode.opModeIsActive(); i++) {
myServo.setPosition(0.5); // move servo clockwise
linearOpMode.sleep(duration); // wait for 'duration'
myServo.setPosition(0); // move servo counterclockwise
linearOpMode.sleep(duration); // wait for 'duration'
}
} // end method wiggleServo()
} // end class SampleMyBlocks_v01