stepper-motor
Arduino library to accurately control a stepper motor
|
Driver for an 8-step stepper motor More...
#include <stepper_motor.h>
Public Member Functions | |
Driver (std::initializer_list< uint8_t > pins) | |
Create a new driver instance using the given pins. More... | |
void | turn (int16_t degree) |
Relative turn. More... | |
void | turnTo (uint16_t target_angle) |
Absolute turn. More... | |
void | setStepsPerRotation (uint16_t steps) |
Set the steps needed for one complete rotation. More... | |
void | setWaiter (void(*waiter)(unsigned int)) |
Set a custom waiter. More... | |
Driver for an 8-step stepper motor
Definition at line 24 of file stepper_motor.h.
StepperMotor::Driver::Driver | ( | std::initializer_list< uint8_t > | pins | ) |
Create a new driver instance using the given pins.
pins | Exactly 4 pins. |
Definition at line 17 of file stepper_motor.cpp.
void StepperMotor::Driver::setStepsPerRotation | ( | uint16_t | steps | ) |
Set the steps needed for one complete rotation.
This defaults to 510, which is a common value for stepper motors found in arduino starter kits.
steps | The steps per rotation. |
Definition at line 63 of file stepper_motor.cpp.
void StepperMotor::Driver::setWaiter | ( | void(*)(unsigned int) | waiter | ) |
Set a custom waiter.
Use this if you want to run some code while the motor is turning. Your custom function must wait at least the given amount of microseconds before returning. The default is delayMicroseconds
.
waiter | The new waiter function. |
Definition at line 67 of file stepper_motor.cpp.
void StepperMotor::Driver::turn | ( | int16_t | degree | ) |
Relative turn.
This turns the motor the given number of degrees in the direction given by the sign (positive = turn right). Supports turns larger than one complete turn (360°).
degree | The number of degree to turn the motor. |
Definition at line 26 of file stepper_motor.cpp.
void StepperMotor::Driver::turnTo | ( | uint16_t | target_angle | ) |
Absolute turn.
Turn the motor to the given angle. Always uses the shortest path to the requested angle and even works after relative turns.
target_angle | The target angle in degree. |
Definition at line 46 of file stepper_motor.cpp.