ftc2024-robotcode/encoder.java

10 lines
471 B
Java
Raw Normal View History

2024-03-16 11:33:11 +01:00
DcMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); // tare the encoder
2024-03-16 11:51:33 +01:00
DcMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);// bloque le motor
2024-03-16 11:50:33 +01:00
// Position droite = 8 ticks
// position initiale = 0 ticks
// position allongée = - 16 ticks
2024-03-16 11:33:11 +01:00
// in opMode:
2024-03-16 11:51:33 +01:00
int pos_to_go = 8; // position to go
2024-03-16 11:33:11 +01:00
DcMotor.setTargetPosition(pos_to_go); // set target position, the motor will run to this pos
DcMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION); // mode run to position