upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members
StepMotor Class Reference

API for the Stepper Motor. More...

Detailed Description

This module defines the Stepper Motor interface. It is compatible with stepper motor drivers that use 2 pins to control the motor, like an Easy Driver from Brian Schmalz.

stepmotor.jpg
while (true) {
sensor.setSpeed(500);
sensor.stepForward(500);
Thread.sleep(10);
sensor.stepBackwards(500);
Thread.sleep(10);
sensor.setSpeed(750);
sensor.stepForward(500);
Thread.sleep(10);
sensor.stepBackwards(500);
Thread.sleep(10);
sensor.setSpeed(1000);
sensor.stepForward(500);
Thread.sleep(10);
sensor.stepBackwards(500);
Thread.sleep(10);
}

Public Member Functions

synchronized void delete ()
 
 StepMotor (int dirPin, int stePin)
 
void setSpeed (int speed)
 
int stepForward (int ticks)
 
int stepBackwards (int ticks)
 

Constructor & Destructor Documentation

StepMotor ( int  dirPin,
int  stePin 
)

Instantiates a StepMotor object

Parameters
dirPinDirection GPIO pin
stePinStepper pulse PWM pin

Member Function Documentation

void setSpeed ( int  speed)

StepMotor object destructor no need for the destructor; all the connections will be closed when m_dirPinCtx and m_pwmStepContext go out of scope ~StepMotor (); Sets the rotation speed

Parameters
speedRotation speed
int stepBackwards ( int  ticks)

Rotates the motor backward

Parameters
ticksNumber of ticks the motor moves
int stepForward ( int  ticks)

Rotates the motor forward

Parameters
ticksNumber of ticks the motor moves

The documentation for this class was generated from the following file: