java.lang.Object
com.pi4j.crowpi.components.Component
com.pi4j.crowpi.components.StepMotorComponent
Implementation of the CrowPi Step Motor using GPIO with Pi4J
-
Field Summary
-
Constructor Summary
ConstructorDescriptionStepMotorComponent
(com.pi4j.context.Context pi4j) Creates a new step motor component with the default pins, steps and pulse duration.StepMotorComponent
(com.pi4j.context.Context pi4j, int[] addresses, int[][] steps, long pulseMilliseconds) Creates a new step motor component with custom pins, steps and pulse duration. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.pi4j.io.gpio.digital.DigitalOutputConfig
buildDigitalOutputConfig
(com.pi4j.context.Context pi4j, int address) Builds a new digital output configuration for the GPIO step motor pinprotected com.pi4j.io.gpio.digital.DigitalOutput[]
Returns an array of all initialized digital outputs for this componentvoid
turnBackward
(int steps) Turns the step motor backward for the given amount of steps.void
turnDegrees
(int degrees) Turns the step motor by the given amount of degrees.void
turnForward
(int steps) Turns the step motor forward for the given amount of steps.Methods inherited from class com.pi4j.crowpi.components.Component
sleep, triggerSimpleEvent
-
Constructor Details
-
StepMotorComponent
public StepMotorComponent(com.pi4j.context.Context pi4j) Creates a new step motor component with the default pins, steps and pulse duration.- Parameters:
pi4j
- Pi4J context
-
StepMotorComponent
public StepMotorComponent(com.pi4j.context.Context pi4j, int[] addresses, int[][] steps, long pulseMilliseconds) Creates a new step motor component with custom pins, steps and pulse duration.The first dimension of
steps
represents the various steps which are to be executed in order. The second dimension ofsteps
represents which output(s) should be pulsed for the current step. Please note that the second dimension does not store the pin addresses but the index withinaddresses
.- Parameters:
pi4j
- Pi4J contextaddresses
- Array of BCM pin addresses to be driven during stepssteps
- Two-dimensional array containing steps with their associated pinspulseMilliseconds
- Duration in milliseconds for pulses
-
-
Method Details
-
turnDegrees
public void turnDegrees(int degrees) Turns the step motor by the given amount of degrees. If a negative value is specified, the motor will automatically turn backward.- Parameters:
degrees
- Number of degrees to turn for- or backward
-
turnForward
public void turnForward(int steps) Turns the step motor forward for the given amount of steps.- Parameters:
steps
- Steps to turn forward
-
turnBackward
public void turnBackward(int steps) Turns the step motor backward for the given amount of steps.- Parameters:
steps
- Steps to turn backward
-
getDigitalOutputs
protected com.pi4j.io.gpio.digital.DigitalOutput[] getDigitalOutputs()Returns an array of all initialized digital outputs for this component- Returns:
- Digital output instances
-
buildDigitalOutputConfig
protected com.pi4j.io.gpio.digital.DigitalOutputConfig buildDigitalOutputConfig(com.pi4j.context.Context pi4j, int address) Builds a new digital output configuration for the GPIO step motor pin- Parameters:
pi4j
- Pi4J contextaddress
- BCM address- Returns:
- Digital output configuration
-