Create encoder.java

This commit is contained in:
Zelina974 2024-03-16 11:33:11 +01:00 committed by GitHub
parent a2e53bd42f
commit c68329989d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

6
encoder.java Normal file
View file

@ -0,0 +1,6 @@
DcMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); // tare the encoder
// in opMode:
int pos_to_go = ...; // position to go
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