Package com.diozero.devices.motor
Class TB6612FNGMotor
- java.lang.Object
-
- com.diozero.devices.motor.MotorBase
-
- com.diozero.devices.motor.TB6612FNGMotor
-
- All Implemented Interfaces:
DeviceInterface
,MotorInterface
,AutoCloseable
public class TB6612FNGMotor extends MotorBase
Bi-directional motor controlled by a single PWM pin and separate forward / backward GPIO pins. Toshiba TB6612FNG Dual Motor Driver such as this one from Pololu.- Turn forward
- set pin 1 to HIGH, pin 2 to LOW, and PWM to >0.
- Turn backward
- set pin 1 to LOW, pin 2 to HIGH, PWM to >0.
-
-
Constructor Summary
Constructors Constructor Description TB6612FNGMotor(DigitalOutputDevice motorForwardControlPin, DigitalOutputDevice motorBackwardControlPin, PwmOutputDevice motorPwmControl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
backward(float speed)
void
close()
Close this devicevoid
forward(float speed)
float
getValue()
Represents the speed of the motor as a floating point value between -1 (full speed backward) and 1 (full speed forward)boolean
isActive()
void
stop()
-
Methods inherited from class com.diozero.devices.motor.MotorBase
addListener, removeListener, reverse, setValue, valueChanged, whenBackward, whenForward, whenStop
-
-
-
-
Constructor Detail
-
TB6612FNGMotor
public TB6612FNGMotor(DigitalOutputDevice motorForwardControlPin, DigitalOutputDevice motorBackwardControlPin, PwmOutputDevice motorPwmControl)
-
-
Method Detail
-
close
public void close()
Description copied from interface:DeviceInterface
Close this device
-
forward
public void forward(float speed) throws RuntimeIOException
- Parameters:
speed
- Range 0..1- Throws:
RuntimeIOException
- if an I/O error occurs
-
backward
public void backward(float speed) throws RuntimeIOException
- Parameters:
speed
- Range 0..1- Throws:
RuntimeIOException
- if an I/O error occurs
-
stop
public void stop() throws RuntimeIOException
- Throws:
RuntimeIOException
-
getValue
public float getValue() throws RuntimeIOException
Represents the speed of the motor as a floating point value between -1 (full speed backward) and 1 (full speed forward)- Throws:
RuntimeIOException
- if an I/O error occurs
-
isActive
public boolean isActive() throws RuntimeIOException
- Throws:
RuntimeIOException
-
-