Show:

BO.io.DCMotor Class

Defined in: src/io/DCMotor.js:21

Creates an interface to an H-bridge to control the direction of rotation of a motor shaft. You can rotate forward (clockwise), reverse or apply a brake. See Breakout/examples/actuators/dcmotor.html for an example application.

Tested successfully with the following H-bridge: SN754410
Should also be compatible with the following:
SN754410
L293NE
TA7291P
TB6612FNG
BD621F

Constructor

BO.io.DCMotor

(
  • board
  • forwardPin
  • reversePin
  • pwmPin
  • minVoltage
  • maxVoltage
  • supplyVoltage
)

Parameters:

  • board IOBoard

    A reference to the IOBoard instance that the servo is attached to.

  • forwardPin Pin

    A reference to the Pin connected to the forward control of the H-bridge.

  • reversePin Pin

    A reference to the Pin connected to the reverse control of the H-bridge.

  • pwmPin Pin

    A reference to the Pin connected to the pwm control of the H-bridge.

  • minVoltage Number

    The minimum voltage (default = 1).

  • maxVoltage Number

    The maximum voltage (default = 9).

  • supplyVoltage Number

    The supply voltage (default = 9).

Item Index

Properties

Methods

despin

(
  • useBrake
)

Parameters:

  • useBrake Boolean

    Default = true

forward

(
  • val
)

Parameters:

  • val Number

    The new voltage to set (0.0 to 1.0)

reverse

(
  • val
)

Parameters:

  • val Number

    The new voltage to set (-1.0 to 0.0)

Properties

value

Number

The value of the motor speed (-1.0 to 1.0). A speed of zero stops the motor.