.SetDegree( )

back to FEHServo

Description

This function allows the user to set the angle of a servo object. The servos that are provided have a range of 0.0º to 180.0º. The angle of the servo will hold at this angle until another .SetDegree() function is called or the .Off() command is called. In order to receive the best results and to prevent wear on the servo, you will need to calibrate each servo you plan to use and set the minimum and maximum values accordingly.

Syntax

.SetDegree( float angle )

Parameters

angle: Float value in degrees that the servo is set to (range from 0.0º to 180.0º)

Returns

None.

Examples

#include <FEHServo.h>
//need FEHUtility.h for Sleep()
#include <FEHUtility.h>

#define SERVO_MIN 500
#define SERVO_MAX 2250

int main(void)
{
    //declares a servo on servo port 3
    FEHServo arm_servo(FEHServo::Servo3); 

    //enter the minimum and maximum servo values
    //from the .TouchCalibrate() function
    arm_servo.SetMin(SERVO_MIN);
    arm_servo.SetMax(SERVO_MAX);

    //set the servo angle to it's initial angle
    arm_servo.SetDegree(90.);
    
    //wait 5 seconds
    Sleep(5.0);

    //move the arm to next angle
    arm_servo.SetDegree(114.5);
}