Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Stepper Class Reference
Class library for a Stepper Motor to be able to Select amount of steps,set the time interval between steps, run stepper motor freely and stop the stepper motor. More...
#include <Stepper.h>
Public Member Functions | |
| Stepper (PinName Coil1, PinName Coil2, PinName Coil3, PinName Coil4) | |
| Create a Stepper motor object connected to the specified pins. | |
| void | Run () |
| Makes the stepper run continuously. | |
| void | Stop () |
| To make stepper stop. | |
| void | Direction (bool dir) |
| Setting direction of the stepper motor, Clockwise or Anticlockwise. | |
| void | Interval (float sec) |
| Choosing time interval between steps(control speed). | |
| void | Step (int steps) |
| Selct amount of steps the stpper motor should turn. | |
Detailed Description
Class library for a Stepper Motor to be able to Select amount of steps,set the time interval between steps, run stepper motor freely and stop the stepper motor.
Example:
#include "mbed.h" //include the mbed APIs and other libraries #include "Stepper.h" //include the Stepper librariy Stepper stepper (PE_4, PE_5, PE_6, PE_7); //Initialize bus pins int main() { while(1) //Enter infinite while loop { stepper.Interval(0.1); //Choosing time interval between steps(control speed) stepper.Direction(true); //Choosing direction. true = Clockwise, false = Anticlockwise stepper.Run(); //Makes the stepper run continuously wait(5); //mbed's wait function, wait 5 sec. stepper.Direction(false); wait(5); stepper.Stop(); //To make stepper stop wait(5); } }
Definition at line 57 of file Stepper.h.
Constructor & Destructor Documentation
| Stepper | ( | PinName | Coil1, |
| PinName | Coil2, | ||
| PinName | Coil3, | ||
| PinName | Coil4 | ||
| ) |
Create a Stepper motor object connected to the specified pins.
- Parameters:
-
coil1 MCU Output Pin for coil1. coil2 MCU Output Pin for coil2. coil3 MCU Output Pin for coil3. coil4 MCU Output Pin for coil4.
Definition at line 4 of file Stepper.cpp.
Member Function Documentation
| void Direction | ( | bool | dir ) |
Setting direction of the stepper motor, Clockwise or Anticlockwise.
- Parameters:
-
boolean slection to select direction. true = Clockwise, false = Anticlockwise
Definition at line 42 of file Stepper.cpp.
| void Interval | ( | float | sec ) |
Choosing time interval between steps(control speed).
- Parameters:
-
A float value to set the time between steps.
- Returns:
- None
Definition at line 54 of file Stepper.cpp.
| void Run | ( | ) |
| void Step | ( | int | steps ) |
Selct amount of steps the stpper motor should turn.
- Parameters:
-
interger value to select the amount of steps.
- Returns:
- None
Definition at line 64 of file Stepper.cpp.
| void Stop | ( | ) |
Generated on Wed Jul 13 2022 00:05:57 by
1.7.2