
Very simple operation samples of unipolar stepper motor. This code has been made to help beginners to learn the stepper motor. The history of the code shows the how to generate pulses from very basic level.
Diff: main.cpp
- Revision:
- 3:db008e5009d0
- Parent:
- 2:e9fbf2c17789
- Child:
- 4:3cb4e78e0846
--- a/main.cpp Sat Jan 11 01:31:36 2014 +0000 +++ b/main.cpp Sat Jan 11 01:34:59 2014 +0000 @@ -1,7 +1,7 @@ // stepper motor operation sample (learn it step by step). // showing how to control a unipolar stepper motor by mbed digital output ports. // -// version 1 : Output pulses to p23, p24, p25 and p26 ports +// version 1-1 : Rotate motor in reverse direction #include "mbed.h" @@ -16,9 +16,15 @@ while(1) { - motor_out0 = 1; + motor_out0 = 0; motor_out1 = 0; motor_out2 = 0; + motor_out3 = 1; + wait( INTERVAL ); + + motor_out0 = 0; + motor_out1 = 0; + motor_out2 = 1; motor_out3 = 0; wait( INTERVAL ); @@ -28,16 +34,10 @@ motor_out3 = 0; wait( INTERVAL ); - motor_out0 = 0; - motor_out1 = 0; - motor_out2 = 1; - motor_out3 = 0; - wait( INTERVAL ); - - motor_out0 = 0; + motor_out0 = 1; motor_out1 = 0; motor_out2 = 0; - motor_out3 = 1; + motor_out3 = 0; wait( INTERVAL ); } }