Servo Commands
Last updated
Was this helpful?
Last updated
Was this helpful?
To set the position of the servo, just use setPosition(angle). You can set the servo angle to any number between 0 and 1.0. This decimal number represents a percentage of the total number of degrees the servo is able to rotate. For example, if you wrote:
and the servo could rotate 270 degrees, the servo would rotate to (270*0.5) = 135 degrees.
Right now your servo should not have anything attached to it. If it does, you risk running your servo into something and breaking it!
Open up your original RemoteControlDrive. This OpMode should have all your Drive code in it, we will just add servo control to it.
Add one or more Servo objects to your robot hardware section…
Create a few new variables right inside your runOpMode like so:
Tell your robot controller where to find your servos in the hardwareMap sectiono
Add the following code to control your servos. This will go in the main loop.
Take a few minutes to move your servo around and jot down their desired minimum and maximum positions.
Min _____________ Max ____________