-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBungerLesson2.java
54 lines (39 loc) · 1.31 KB
/
BungerLesson2.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package RobotCode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.util.ElapsedTime;
@TeleOp(name="Bunger Lesson 2", group="Iterative Opmode")
public class BungerLesson2 extends OpMode {
private DcMotor armPower;
private int armState = 0;
private ElapsedTime runtime = new ElapsedTime();
private ElapsedTime AStoggleCooldown = new ElapsedTime();
@Override
public void init() {
armState = 3;
AStoggleCooldown = 0;
armPower = hardwareMap.get(DcMotor.class, "arm");
}
@Override
//WHILE LOOP
public void loop() {
runtime = 0;
//cooldown + set power
if((runtime-AStoggleCooldown) >= 0.2){
if(gamepad1.x) {
if(armState == 1) {
armPower.setPower(0.5);
armState++;
} else if(armState == 2) {
armPower.setPower(1.0);
armState++;
} else if(armState == 3)
armPower.setPower(0.0);
armState = 1;
}
}
}
}
}
}