I ama beginner programmer in terms of the Robotics API (WpiLibJ) and I've been studying a bit of it and I came up with this piece of code to drive the robot forward and then have the piston retract and extract with 1 second delays as test. Can someone clarify if this works, and if not, please help me figure out why it doesn't work. It'd also be awesome if someone can reference a FRC Java guide that takes me through the basic procedure of getting me started in learning the API.
Code:
# = placeholder for real value
Code:
RobotDrive theRobot = new RobotDrive(#);
Timer timer = new Timer();
Relay spike = new Relay(#);
Solenoid piston = new Solenoid(#);
Compressor compressor1 = new Compressor(#);
public void autonomous() { //checks code every 50 seconds
theRobot.setSafetyEnabled(false);
theRobot.drive(-1, 0.0);
timer.delay(2.0);
theRobot.drive(0.0, 0.0);
compressor1.start();
piston.set(true);
for (int x = 0; x < 5; x++) {
spike.set(Relay.Value.kForward);
timer.delay(1.0);
spike.set(Relay.Value.kReverse);
timer.delay(1.0);
}
piston.set(false);
}