MRAA

MRAA is a low level skeleton library for communication on GNU/Linux platforms. See examples here.

Pwm Class

Module: mraa

This file defines the PWM interface for libmraa

Methods

Pwm

(
  • pin
  • owner
  • chipid
)
Number

instanciates a PWM object on a pin

Parameters:

  • pin Number

    the pin number used on your board

  • owner Boolean

    if you are the owner of the pin the destructor will unexport the pin from sysfs, default behaviour is you are the owner if the pinmapper exported it

  • chipid Number

    the pwmchip to use, use only in raw mode

Returns:

Number:

write

(
  • percentage
)
Enum Result

Set the output duty-cycle percentage, as a float

Parameters:

  • percentage Number

    A floating-point value representing percentage of output. The value should lie between 0.0f (representing 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f

Returns:

Enum Result:

Result of operation

read

() Number

Read the output duty-cycle percentage, as a float

Returns:

Number:

A floating-point value representing percentage of output. The value should lie between 0.0f (representing 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f

period

(
  • period
)
Enum Result

Set the PWM period as seconds represented in a float

Parameters:

  • period Number

    Period represented as a float in seconds

Returns:

Enum Result:

Result of operation

period_ms

(
  • ms
)
Enum Result

Set period, milliseconds

Parameters:

  • ms Number

    milliseconds for period

Returns:

Enum Result:

Result of operation

period_us

(
  • us
)
Enum Result

Set period, microseconds

Parameters:

  • us Number

    microseconds as period

Returns:

Enum Result:

Result of operation

pulsewidth

(
  • seconds
)
Enum Result

Set pulsewidth, as represented by seconds in a float

Parameters:

  • seconds Number

    The duration of a pulse

Returns:

Enum Result:

Result of operation

pulsewidth_ms

(
  • ms
)
Enum Result

Set pulsewidth, milliseconds

Parameters:

  • ms Number

    milliseconds for pulsewidth

Returns:

Enum Result:

Result of operation

pulsewidth_us

(
  • us
)
Enum Result

The pulsewidth, microseconds

Parameters:

  • us Number

    microseconds for pulsewidth

Returns:

Enum Result:

Result of operation

enable

(
  • enable
)
Enum Result

Set the enable status of the PWM pin. None zero will assume on with output being driven and 0 will disable the output

Parameters:

  • enable Boolean

    enable status of pin

Returns:

Enum Result:

Result of operation

max_period

() Number

Get the maximum PWM period in us

Returns:

Number:

max PWM period in us

min_period

() Number

Get the minimum PWM period in us

Returns:

Number:

min PWM period in us