UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

Servo Class

Module: servo

Methods

Servo

(
  • pin
)
Number

Instantiates a Servo object

Parameters:

  • pin Number

    Servo pin number

Returns:

Number:

Servo

(
  • pin
  • minPulseWidth
  • maxPulseWidth
)
Number

Instantiates a Servo object

Parameters:

  • pin Number

    Servo pin number

  • minPulseWidth Number

    Minimum pulse width, in microseconds

  • maxPulseWidth Number

    Maximum pulse width, in microseconds

Returns:

Number:

Servo

(
  • pin
  • minPulseWidth
  • maxPulseWidth
  • waitAndDisablePwm
)
Number

Instantiates a Servo object

Parameters:

  • pin Number

    Servo pin number

  • minPulseWidth Number

    Minimum pulse width, in microseconds

  • maxPulseWidth Number

    Maximum pulse width, in microseconds

  • waitAndDisablePwm Number

    If 1, PWM is enabled only during the setAngle() execution for a period of 1 second, and then turned back off. If 0, PWM remains on afterward.

Returns:

Number:

setAngle

(
  • angle
)
Mraa_result_t

Sets the angle of the servo engine.

Parameters:

  • angle Number

    Number between 0 and 180

Returns:

Mraa_result_t:

0 if successful, non-zero otherwise

haltPwm

() Mraa_result_t

Halts PWM for this servo and allows it to move freely.

Returns:

Mraa_result_t:

name

() String

Returns the name of the component

Returns:

String:

Name of the component

setMinPulseWidth

(
  • width
)

Sets the minimum pulse width

Parameters:

  • width Number

    Minimum HIGH signal width

setMaxPulseWidth

(
  • width
)

Sets the maximum pulse width

Parameters:

  • width Number

    Maximum HIGH signal width

setPeriod

(
  • period
)

Sets the maximum period width

Parameters:

  • period Number

    PWM period width

getMinPulseWidth

() Number

Returns the minimum pulse width

Returns:

Number:

Minimum pulse width

getMaxPulseWidth

() Number

Returns the maximum pulse width

Returns:

Number:

Maximum pulse width

getPeriod

() Number

Returns the maximum PWM period width

Returns:

Number:

Maximum PWM period width