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:
- 2:d9745be6c253
- Parent:
- 1:40e5ac1119a6
--- a/stepper.cpp Tue Jul 12 13:02:25 2022 -0400 +++ b/stepper.cpp Thu Aug 04 15:14:29 2022 -0400 @@ -1,3 +1,4 @@ +#include <cstdio> #include <mbed.h> #include "stepper.h" #include <chrono> @@ -8,17 +9,31 @@ 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;} - + PinName ms3_pin, + PinName sleep_pin) + : enable(enable_pin), step(step_pin), dir(dir_pin), ms1(ms1_pin), + ms2(ms2_pin), ms3(ms3_pin), sleep(sleep_pin), count(0) { + enable = 0; + sleep = 1; + step = 0; + } + void StepperMotor::step_positive() { dir = 0; step = 1; - wait_us(40); + + wait_us(40000); + if (step == 1) { + printf("step rise\n"); + }; + if (step == 0){ + printf("step fall, also something is wrong\n"); + }; + step = 0; - wait_us(40); + + wait_us(40000); + printf("one step taken\n"); } void StepperMotor::step_negative() {