AccelMotor for Mbed

Dependencies:   mbed

Dependents:   stepMotor

Committer:
abckcp
Date:
Tue Feb 14 22:50:03 2017 +0000
Revision:
3:8d5c0d22d61d
Parent:
1:71768fb30886
Nucleo_read_analog_values Alicia

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yweng36 0:a0391774b0e5 1 /*
yweng36 0:a0391774b0e5 2 sample program for AccelStepper.h
yweng36 0:a0391774b0e5 3 inspired by the Bounce example of the Arduino version
yweng36 0:a0391774b0e5 4
yweng36 0:a0391774b0e5 5
yweng36 0:a0391774b0e5 6 */
yweng36 0:a0391774b0e5 7 #include "AccelStepper.h"
yweng36 0:a0391774b0e5 8
yweng36 0:a0391774b0e5 9 /**
yweng36 0:a0391774b0e5 10 *** Main function
yweng36 0:a0391774b0e5 11 **/
yweng36 0:a0391774b0e5 12
BalB 1:71768fb30886 13 /*AccelStepper stepper(4, p21, p22, p23, p24); */
yweng36 0:a0391774b0e5 14
yweng36 0:a0391774b0e5 15 Timer t;
BalB 1:71768fb30886 16 /*
yweng36 0:a0391774b0e5 17 int main()
yweng36 0:a0391774b0e5 18 {
yweng36 0:a0391774b0e5 19 t.start();
yweng36 0:a0391774b0e5 20 stepper.setMaxSpeed(200);
yweng36 0:a0391774b0e5 21 stepper.setAcceleration(50);
yweng36 0:a0391774b0e5 22 stepper.moveTo(500);
yweng36 0:a0391774b0e5 23 stepper.setMinPulseWidth(50);
yweng36 0:a0391774b0e5 24
yweng36 0:a0391774b0e5 25
yweng36 0:a0391774b0e5 26
yweng36 0:a0391774b0e5 27 while (true) {
yweng36 0:a0391774b0e5 28 if (stepper.distanceToGo() == 0)
yweng36 0:a0391774b0e5 29 stepper.moveTo(-stepper.currentPosition());
yweng36 0:a0391774b0e5 30 stepper.run();
yweng36 0:a0391774b0e5 31 }
yweng36 0:a0391774b0e5 32 }
BalB 1:71768fb30886 33 */
yweng36 0:a0391774b0e5 34