forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistanceTest.java
More file actions
28 lines (24 loc) · 983 Bytes
/
DistanceTest.java
File metadata and controls
28 lines (24 loc) · 983 Bytes
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 com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import com.qualcomm.robotcore.hardware.DistanceSensor;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
@TeleOp
@Disabled
public class DistanceTest extends LinearOpMode {
DistanceSensor distance;
@Override
public void runOpMode() {
// Get the distance sensor and motor from hardwareMap
distance = hardwareMap.get(DistanceSensor.class, "2m");
// Loop while the Op Mode is running
waitForStart();
while (opModeIsActive()) {
// If the distance in centimeters is less than 10, set the power to 0.3
telemetry.addLine(String.valueOf(distance.getDistance(DistanceUnit.CM)));
telemetry.update();
}
}
}