-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSweeper.java
More file actions
55 lines (53 loc) · 1.92 KB
/
Sweeper.java
File metadata and controls
55 lines (53 loc) · 1.92 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
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
55
package frc.robot;
//import your motor controllers, compressors, solenoids, and physical controllers using this pattern.
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
public class Sweeper {
//set your pistons to default positions
public static boolean fourBarS = false;
public static boolean compressorT = false;
//name your motors, controller, and make the public static void drive here.
public static Spark left = new Spark(0);
public static Spark right = new Spark(1);
public static Spark grab = new Spark(2);
public static XboxController driver = new XboxController(3);
public static Compressor compressor = new Compressor();
public static Solenoid fourBar = new Solenoid(blank);
public static void drive(){
//set your speeds
double speed = 0.5;
double grabber = 0.2;
//drivetrain
left.set(driver.getRawAxis(1) *speed);
right.set(driver.getRawAxis(3)*speed);
//graber on Sweeper
if (driver.getRawButton(8)){
grab.set(grabber);
} else if (driver.getRawButton(7)); {
grab.set(-grabber);
} else {
grab.set(0);
}
//piston controls
if (driver.getRawButtonPressed(2)){
if (compressorT) {
compressor.start();
compressorT = false;
} else if (!compressorT) {
compressor.stop();
compressorT = true;
}
if (driver.getRawButtonPressed(3)) {
if (fourBarS) {
fourBar.startPulse();
fourBarS = false;
} else if (!fourBarS) {
fourBar.startPulse();
fourBarS = true;
}
}
}
}
}