![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Stepper motor moves in steps depending on the 4 bit input given by switches
Dependencies: StepperMotorUni mbed
Revision 0:d3f9c4187789, committed 2016-02-05
- Comitter:
- EduRemo
- Date:
- Fri Feb 05 07:33:38 2016 +0000
- Commit message:
- FRCRCE Stepper motor
Changed in this revision
diff -r 000000000000 -r d3f9c4187789 StepperMotorUni.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/StepperMotorUni.lib Fri Feb 05 07:33:38 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/okano/code/StepperMotorUni/#93f9ce526f38
diff -r 000000000000 -r d3f9c4187789 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Feb 05 07:33:38 2016 +0000 @@ -0,0 +1,102 @@ +// "Hello" program for StepperMotorUni class library + + +#include "mbed.h" +#include "StepperMotorUni.h" + +StepperMotorUni motor( PTB0, PTB1, PTB2, PTB3); + +DigitalIn sw0(PTD1); // Switch selected as input +DigitalIn sw1(PTD3); +DigitalIn sw2(PTD2); +DigitalIn sw3(PTD0); + +int main() +{ motor.set_pps( 200 ); + while (1) + { + if (sw0==0 && sw1==0 && sw2==0 && sw3==0) + { + motor.move_steps(150); + } + else if (sw0==0 && sw1==0 && sw2==0 && sw3==1) + { + motor.move_steps(140); + wait(5); + } + else if (sw0==0 && sw1==0 && sw2==1 && sw3==0) + { + motor.move_steps(130); + wait(5); + } + else if (sw0==0 && sw1==0 && sw2==1 && sw3==1) + { + motor.move_steps(120); + wait(5); + } + else if (sw0==0 && sw1==1 && sw2==0 && sw3==0) + { + motor.move_steps(110); + wait(5); + } + else if (sw0==0 && sw1==1 && sw2==0 && sw3==1) + { + motor.move_steps(100); + wait(5); + } + else if (sw0==0 && sw1==1 && sw2==1 && sw3==0) + { + motor.move_steps(90); + wait(5); + } + else if (sw0==0 && sw1==1 && sw2==1 && sw3==1) + { + motor.move_steps(80); + wait(5); + } + else if (sw0==1 && sw1==0 && sw2==0 && sw3==0) + { + motor.move_steps(70); + wait(5); + } + else if (sw0==1 && sw1==0 && sw2==0 && sw3==1) + { + motor.move_steps(60); + wait(5); + } + else if (sw0==1 && sw1==0 && sw2==1 && sw3==0) + { + motor.move_steps(50); + wait(5); + } + else if (sw0==1 && sw1==0 && sw2==1 && sw3==1) + { + motor.move_steps(40); + wait(5); + } + else if (sw0==1 && sw1==1 && sw2==0 && sw3==0) + { + motor.move_steps(30); + wait(5); + } + else if (sw0==1 && sw1==1 && sw2==0 && sw3==1) + { + motor.move_steps(20); + wait(5); + } + else if (sw0==1 && sw1==1 && sw2==1 && sw3==0) + { + motor.move_steps(10); + wait(5); + } + else if (sw0==1 && sw1==1 && sw2==1 && sw3==1) + { + motor.move_steps(00); + wait(5); + } + else + { + motor.move_steps(0); + } + } +} \ No newline at end of file
diff -r 000000000000 -r d3f9c4187789 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Feb 05 07:33:38 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32 \ No newline at end of file