Package com.diozero.devices.motor
Class DigitalMotor
- java.lang.Object
-
- com.diozero.devices.motor.DigitalMotor
-
- All Implemented Interfaces:
DeviceInterface
,AutoCloseable
public class DigitalMotor extends Object implements DeviceInterface
-
-
Constructor Summary
Constructors Constructor Description DigitalMotor(int forwardGpio, int backwardGpio)
DigitalMotor(GpioDeviceFactoryInterface deviceFactory, int forwardGpio, int backwardGpio)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
backward()
void
close()
Close this devicevoid
forward()
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
reverse()
void
stop()
-
-
-
Constructor Detail
-
DigitalMotor
public DigitalMotor(int forwardGpio, int backwardGpio) throws RuntimeIOException
- Throws:
RuntimeIOException
-
DigitalMotor
public DigitalMotor(GpioDeviceFactoryInterface deviceFactory, int forwardGpio, int backwardGpio) throws RuntimeIOException
- Throws:
RuntimeIOException
-
-
Method Detail
-
close
public void close()
Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
forward
public void forward() throws RuntimeIOException
- Throws:
RuntimeIOException
-
backward
public void backward() throws RuntimeIOException
- Throws:
RuntimeIOException
-
stop
public void stop() throws RuntimeIOException
- Throws:
RuntimeIOException
-
reverse
public void reverse() throws RuntimeIOException
- Throws:
RuntimeIOException
-
isActive
public boolean isActive() 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)- Returns:
- current value for this motor in the range -1 (backwards) to 1 (forwards)
- Throws:
RuntimeIOException
- if an I/O error occurs
-
-