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.
Fork of stepper by
Diff: stepper.cpp
- Revision:
- 1:bbb51c42e7d2
- Parent:
- 0:0774a793a83b
- Child:
- 2:e537d08c705b
diff -r 0774a793a83b -r bbb51c42e7d2 stepper.cpp
--- a/stepper.cpp Wed Jul 25 07:26:01 2018 +0000
+++ b/stepper.cpp Wed Jul 25 07:51:33 2018 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "stepper.h"
+
+void stepperMotor::init()
+{
+ remain = 0;
+ en = 0;
+ dir = 0;
+
+}
+
+void stepper::moveStepper()
+{
+ if(remain == 0)
+ return;
+ if(step)
+ {
+ step = 0; //STEP 1->0
+ remain--;
+ }
+ else
+ {
+ step = 1; //STEP 0->1
+ }
+}
+
+void stepper::stepperMotor(PinName stepPin, PinName dirPin, PinName enPin, float period):step(stepPin), dir(dirPin), en(enPin), remain(0)
+{
+ stepper.attach(&moveStepper, period);
+}
