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.cpp
- Committer:
- fionalin
- Date:
- 2022-07-12
- Revision:
- 1:40e5ac1119a6
- Parent:
- 0:4e3ad938564e
- Child:
- 2:d9745be6c253
File content as of revision 1:40e5ac1119a6:
#include <mbed.h> #include "stepper.h" #include <chrono> //#include <thread> StepperMotor::StepperMotor(PinName enable_pin, PinName step_pin, PinName dir_pin, PinName ms1_pin, PinName ms2_pin, PinName ms3_pin ) : enable(enable_pin), step(step_pin), dir(dir_pin), ms1(ms1_pin), ms2(ms2_pin), ms3(ms3_pin), count(0) {enable = 0;} void StepperMotor::step_positive() { dir = 0; step = 1; wait_us(40); step = 0; wait_us(40); } void StepperMotor::step_negative() { dir = 1; step = 1; wait_us(40); step = 0; wait_us(40); } int32_t StepperMotor::get_steps() { return count; } void StepperMotor::reset_step_count() { count = 0; }