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.
Dependents: Robot2016_2-0_STATIC Robot2016_2-0
Fork of StepperMotor by
Stepper.cpp
- Committer:
- sype
- Date:
- 2016-04-05
- Revision:
- 1:e34729a7567f
- Parent:
- 0:52fb09e87581
- Child:
- 3:c7011e72f0c7
File content as of revision 1:e34729a7567f:
#include "Stepper.h" #include "mbed.h" Stepper::Stepper(PinName _en, PinName _stepPin, PinName _dir):en(_en), stepPin(_stepPin), direction(_dir) { } void Stepper::step(int number, int dir, float speed) { if (dir == 1) { direction = 0; } else if (dir == 0) { direction = 1; } // Step... for(int i=0; i<number; i++) { stepPin = 1; wait_us(5); stepPin = 0; wait_us(5); wait(speed); } } void Stepper::enable() { en = 0; } void Stepper::disable() { en = 1; }