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.

AdafruitMS1438 Class

Module: adafruitms1438

This class implements support for the stepper and DC motors that can be connected to this Motor Shield. Note: the two servo connections are not controlled by the PCA9685 controller (or this class). They are connected directly to digital PWM pins 9 and 10 on the Arduino* breakout board.
adafruitms1438.jpg An example using a DC motor connected to M3 An example using a stepper motor connected to M1 & M2

Methods

AdafruitMS1438

(
  • bus
  • address
)
Number

AdafruitMS1438 constructor

Parameters:

  • bus Number

    I2C bus to use

  • address Number

    Address for this sensor

Returns:

Number:

getMillis

(
  • motor
)
Number

Returns the number of milliseconds elapsed since initClock(...) was last called.

Parameters:

  • motor STEPMOTORS_T

    undefined

Returns:

Number:

Elapsed milliseconds

initClock

(
  • motor
)

Resets the clock

Parameters:

  • motor STEPMOTORS_T

    undefined

setPWMPeriod

(
  • hz
)

Sets the PWM period. Note: this applies to all PWM channels.

Parameters:

  • hz Number

    Sets the PWM period

enableMotor

(
  • motor
)

Enables PWM output for a motor

Parameters:

  • motor DCMOTORS_T

    DC motor to enable

disableMotor

(
  • motor
)

Disables PWM output for a motor

Parameters:

  • motor DCMOTORS_T

    DC motor to disable

enableStepper

(
  • motor
)

Enables output for a stepper motor

Parameters:

  • motor STEPMOTORS_T

    Stepper motor to enable

disableStepper

(
  • motor
)

Disable output for a stepper motor

Parameters:

  • motor STEPMOTORS_T

    Stepper motor to disable

setMotorSpeed

(
  • motor
  • speed
)

set the speed of a DC motor. Values can range from 0 (off) to 100 (full speed).

Parameters:

  • motor DCMOTORS_T

    the DC motor to configure

  • speed Number

    speed to set the motor to

setStepperSpeed

(
  • motor
  • speed
)

Sets the speed of a stepper in revolutions per minute (RPM)

Parameters:

  • motor STEPMOTORS_T

    DC motor to configure

  • speed Number

    Speed to set the motor to

setMotorDirection

(
  • motor
  • dir
)

Sets the direction of a DC motor, clockwise or counterclockwise

Parameters:

  • motor DCMOTORS_T

    DC motor to configure

  • dir DIRECTION_T

    Direction to set the motor in

setStepperDirection

(
  • motor
  • dir
)

Sets the direction of a stepper motor, clockwise or counterclockwise

Parameters:

  • motor STEPMOTORS_T

    Stepper motor to configure

  • dir DIRECTION_T

    Direction to set the motor in

stepConfig

(
  • motor
  • stepsPerRev
)

Sets a stepper motor configuration

Parameters:

  • motor STEPMOTORS_T

    Stepper motor to configure

  • stepsPerRev Number

    Number of steps to complete a full revolution

stepperSteps

(
  • motor
  • steps
)

Steps a stepper motor a specified number of steps

Parameters:

  • motor STEPMOTORS_T

    Stepper motor to step

  • steps Number

    Number of steps to move the stepper motor

Properties

DIR_NONE

Enum DIRECTION_T

DIR_CW

Enum DIRECTION_T

DIR_CCW

Enum DIRECTION_T

MOTOR_M1

Enum DCMOTORS_T

MOTOR_M2

Enum DCMOTORS_T

MOTOR_M3

Enum DCMOTORS_T

MOTOR_M4

Enum DCMOTORS_T

STEPMOTOR_M12

Enum STEPMOTORS_T

STEPMOTOR_M34

Enum STEPMOTORS_T