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.
Diff: stepper.cpp
- Revision:
- 1:40e5ac1119a6
- Parent:
- 0:4e3ad938564e
- Child:
- 2:d9745be6c253
diff -r 4e3ad938564e -r 40e5ac1119a6 stepper.cpp --- a/stepper.cpp Tue Jun 28 21:32:51 2022 +0000 +++ b/stepper.cpp Tue Jul 12 13:02:25 2022 -0400 @@ -3,28 +3,30 @@ #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 = 1; -} +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 = 1; + dir = 0; step = 1; -// ThisThread::sleep_for(1us); + wait_us(40); step = 0; - count++; + wait_us(40); } void StepperMotor::step_negative() { - dir = 0; + dir = 1; step = 1; -// ThisThread::sleep_for(1us); + wait_us(40); step = 0; - count++; + wait_us(40); } int32_t StepperMotor::get_steps() {